Many changes

This commit is contained in:
William Burns 2015-12-11 00:40:54 +00:00
parent 4cf33eef05
commit 626a812844
7 changed files with 208 additions and 120 deletions

View File

@ -12,6 +12,7 @@ import java.util.Map.Entry;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.structs.ItemContainer;
@ -1116,4 +1117,12 @@ public class UtilItem
{
return _materials.containsKey(material);
}
public static ItemStack makeUnbreakable(ItemStack i)
{
ItemMeta im = i.getItemMeta();
im.spigot().setUnbreakable(true);
i.setItemMeta(im);
return i;
}
}

View File

@ -298,6 +298,15 @@ public class GadgetManager extends MiniPlugin
}
}
}
public void DisableParticles()
{
for (Gadget gadget : _gadgets.get(GadgetType.Particle))
{
for (Player player : UtilServer.getPlayers())
gadget.Disable(player);
}
}
public void DisableAll()
{

View File

@ -44,6 +44,8 @@ public class Arena
private HashMap<Player, ArrayList<ParticleData>> _particles;
private ArrayList<Player> _sentParticles;
public Arena(Gladiators host, Location mid, ArenaType colour)
{
_host = host;
@ -59,6 +61,7 @@ public class Arena
_stateTime = System.currentTimeMillis();
_particles = new HashMap<>();
_doBye = false;
_sentParticles = new ArrayList<>();
setupSpawns();
}
@ -256,6 +259,8 @@ public class Arena
{
_isOpenDoor = true;
_sentParticles.clear();
_host.Manager.getScheduler().scheduleSyncDelayedTask(_host.Manager.getPlugin(), () -> {
for (Location loc : _doorBlocks)
@ -281,7 +286,11 @@ public class Arena
for (Player p : getPastPlayers())
{
UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20, 0, p);
if (_sentParticles.contains(p))
continue;
UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20 * 100, 0, p);
_sentParticles.add(p);
}
}
else if (_state.equals(ArenaState.FIGHTING))
@ -308,7 +317,10 @@ public class Arena
{
for (Player p : getPastPlayers())
{
UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20, 0, p);
if (_sentParticles.contains(p))
continue;
UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20 * 100, 0, p);
}
if (UtilTime.elapsed(_stateTime, 15000))

View File

@ -5,21 +5,26 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.UUID;
import java.util.Random;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Golem;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -36,6 +41,7 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -120,8 +126,11 @@ public class Gladiators extends SoloGame
@EventHandler
public void tutorialStart(GameTutorialStartEvent e)
{
Manager.getCosmeticManager().getGadgetManager().DisableParticles(); // Particles blocking tutorial...
Location white = WorldData.GetDataLocs("WHITE").get(0);
Location orange = UtilAlg.findClosest(white, WorldData.GetDataLocs("ORANGE"));
Location purple = WorldData.GetDataLocs("PURPLE").get(0);
Location orange = UtilAlg.findClosest(purple, WorldData.GetDataLocs("ORANGE"));
Location pink = UtilAlg.findClosest(orange, WorldData.GetDataLocs("PINK"));
ArrayList<Location> spawns = new ArrayList<>(WorldData.GetDataLocs("BROWN"));
Location spawn1 = spawns.get(0);
@ -129,41 +138,46 @@ public class Gladiators extends SoloGame
Location spawn2 = spawns.get(0);
e.getTutorial().getPhase(1).setLocation(white);
e.getTutorial().getPhase(1).setTarget(orange);
e.getTutorial().getPhase(1).setTarget(purple);
CreatureAllowOverride = true;
Zombie zombie1 = (Zombie) WorldData.World.spawnEntity(spawn1, EntityType.ZOMBIE);
Zombie zombie2 = (Zombie) WorldData.World.spawnEntity(spawn2, EntityType.ZOMBIE);
Zombie zombie = (Zombie) WorldData.World.spawnEntity(spawn1, EntityType.ZOMBIE);
Golem villager = (Golem) WorldData.World.spawnEntity(spawn2, EntityType.IRON_GOLEM);
CreatureAllowOverride = false;
for (Zombie zombie : Arrays.asList(zombie1, zombie2))
for (LivingEntity ent : Arrays.asList(zombie, villager))
{
GameProfile tiger = new ProfileLoader(UUIDFetcher.getUUIDOf("WilliamTiger").toString(), "WilliamTiger").loadProfile();
GameProfile random = stealGameProfile();
DisguisePlayer player = new DisguisePlayer(zombie, (zombie.equals(zombie1) ? tiger : random));
DisguisePlayer player = new DisguisePlayer(ent, (ent.equals(zombie) ? random : tiger));
Manager.GetDisguise().disguise(player);
UtilEnt.Vegetate(zombie);
zombie.getEquipment().setHelmet(ArenaType.ORANGE.getLoadout().getHelmet());
zombie.getEquipment().setChestplate(ArenaType.ORANGE.getLoadout().getChestplate());
zombie.getEquipment().setLeggings(ArenaType.ORANGE.getLoadout().getLeggings());
zombie.getEquipment().setBoots(ArenaType.ORANGE.getLoadout().getBoots());
zombie.getEquipment().setItemInHand(ArenaType.ORANGE.getLoadout().getSword());
ent.getEquipment().setHelmet(ArenaType.ORANGE.getLoadout().getHelmet());
ent.getEquipment().setChestplate(ArenaType.ORANGE.getLoadout().getChestplate());
ent.getEquipment().setLeggings(ArenaType.ORANGE.getLoadout().getLeggings());
ent.getEquipment().setBoots(ArenaType.ORANGE.getLoadout().getBoots());
ent.getEquipment().setItemInHand(ArenaType.ORANGE.getLoadout().getSword());
UtilEnt.CreatureMoveFast(zombie, orange, 1);
if (ent.equals(villager))
ent.setHealth(100);
//UtilEnt.CreatureMoveFast(zombie, purple, 1);
}
((TutorialGladiators)e.getTutorial()).setOrange(orange);
((TutorialGladiators)e.getTutorial()).setPink(pink);
((TutorialGladiators)e.getTutorial()).setZombie1(zombie1);
((TutorialGladiators)e.getTutorial()).setZombie2(zombie2);
zombie.setTarget(villager);
villager.setTarget(zombie);
((TutorialGladiators) e.getTutorial()).setOrange(orange);
((TutorialGladiators) e.getTutorial()).setPink(pink);
((TutorialGladiators) e.getTutorial()).setZombie(zombie);
((TutorialGladiators) e.getTutorial()).setVillager(villager);
((TutorialGladiators) e.getTutorial()).setPurple(purple);
}
private GameProfile stealGameProfile()
{
Player random = UtilServer.getPlayers()[0];
GameProfile gp = new GameProfile(UUID.randomUUID(), random.getName());
gp.getProperties().putAll(((CraftPlayer)random).getHandle().getProfile().getProperties());
return gp;
List<String> steal = Arrays.asList("Chiss", "Sigils", "Mysticate", "b2_mp", "Bitjump");
String random = steal.get(new Random().nextInt(steal.size()));
return new ProfileLoader(UUIDFetcher.getUUIDOf(random).toString(), random).loadProfile();
}
@EventHandler
@ -196,72 +210,14 @@ public class Gladiators extends SoloGame
if (tutorial.hasEnded())
return;
UtilEnt.CreatureMoveFast(tutorial.getZombie1(), tutorial.getOrange(), 1);
UtilEnt.CreatureMoveFast(tutorial.getZombie2(), tutorial.getOrange(), 1);
if (tutorial.getRunning() >= 2000 && !tutorial.isHasHit1())
if (tutorial.isParticleStage())
{
tutorial.setHasHit1(true);
if (tutorial.getZombie() != null)
tutorial.getZombie().damage(200);
// Zombie hit one
UtilEnt.CreatureMoveFast(tutorial.getVillager(), tutorial.getPink(), 1F);
PacketPlayOutAnimation packet = new PacketPlayOutAnimation();
packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId();
packet.b = 0;
for (Player p : UtilServer.getPlayers())
{
UtilPlayer.sendPacket(p, packet); // Attack effect
}
tutorial.getZombie2().damage(1); // Hurt effect
return;
}
if (tutorial.getRunning() >= 4000 && !tutorial.isHasHit2())
{
tutorial.setHasHit2(true);
// Zombie hit two
PacketPlayOutAnimation packet = new PacketPlayOutAnimation();
packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId();
packet.b = 0;
for (Player p : UtilServer.getPlayers())
{
UtilPlayer.sendPacket(p, packet); // Attack effect
}
tutorial.getZombie2().damage(1); // Hurt effect
return;
}
if (tutorial.getRunning() >= 5000 && !tutorial.getZombie2().isDead())
{
// Zombie remove time
tutorial.getZombie2().damage(1);
UtilFirework.playFirework(tutorial.getZombie2().getLocation(), FireworkEffect.Type.BALL, Color.ORANGE, false, false);
tutorial.getZombie2().remove();
Arena gateArena = getArenaByMid(tutorial.getOrange());
for (Location loc : gateArena.getDoorBlocks())
loc.getBlock().setType(Material.AIR); // Manual door open.
}
if (tutorial.getRunning() > 5000)
{
// Particles
if (tutorial.getZombie1() == null || tutorial.getPink() == null)
return;
UtilEnt.CreatureMoveFast(tutorial.getZombie1(), tutorial.getPink(), 1);
for (Location loc : UtilShapes.getLinesDistancedPoints(tutorial.getZombie1().getLocation(), tutorial.getPink(), 0.2))
for (Location loc : UtilShapes.getLinesDistancedPoints(tutorial.getVillager().getLocation(), tutorial.getPink(), 0.2))
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, loc, 0.03f, 0.03f, 0.03f, 0, 3,
UtilParticle.ViewDist.LONG, UtilServer.getPlayers());
@ -563,8 +519,8 @@ public class Gladiators extends SoloGame
for (Player p : a.getPastPlayers())
{
p.sendMessage(ArcadeFormat.Line);
p.sendMessage(" " + C.cWhite + C.Bold + "You have a bye!");
p.sendMessage(" " + C.cGreen + "You automatically go through this round.");
p.sendMessage(" " + C.cWhite + C.Bold + "Please Wait!");
p.sendMessage(" " + C.cGreen + "Your fight will begin next round.");
p.sendMessage(ArcadeFormat.Line);
}
}
@ -697,8 +653,8 @@ public class Gladiators extends SoloGame
p.getInventory().clear();
p.getInventory().setArmorContents(null);
p.getInventory().setItem(0, type.getLoadout().getSword());
p.getInventory().setItem(1, type.getLoadout().getRod());
p.getInventory().setItem(0, UtilItem.makeUnbreakable(type.getLoadout().getSword()));
p.getInventory().setItem(1, UtilItem.makeUnbreakable(type.getLoadout().getRod()));
p.getInventory().setItem(2, type.getLoadout().getBow());
p.getInventory().setItem(8, type.getLoadout().getArrows());
@ -794,38 +750,94 @@ public class Gladiators extends SoloGame
else if (_roundState.equals(RoundState.STARTING_3))
{
_roundState = RoundState.STARTING_2;
UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0);
for (Player p : UtilServer.getPlayers())
for (Arena a : _gameArenaSet)
{
if (a.getState() != ArenaState.FIGHTING)
continue;
for (Player p : a.getPastPlayers())
{
UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p);
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
}
}
for (Player p : GetPlayers(false))
{
UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p);
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
}
return;
}
else if (_roundState.equals(RoundState.STARTING_2))
{
_roundState = RoundState.STARTING_1;
UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0);
for (Arena a : _gameArenaSet)
{
if (a.getState() != ArenaState.FIGHTING)
continue;
for (Player p : UtilServer.getPlayers())
for (Player p : a.getPastPlayers())
{
UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p);
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
}
}
for (Player p : GetPlayers(false))
{
UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p);
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
}
return;
}
else if (_roundState.equals(RoundState.STARTING_1))
{
_roundState = RoundState.STARTED;
UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0);
for (Arena a : _gameArenaSet)
{
if (a.getState() != ArenaState.FIGHTING)
continue;
for (Player p : UtilServer.getPlayers())
for (Player p : a.getPastPlayers())
{
UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p);
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
}
}
for (Player p : GetPlayers(false))
{
UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p);
p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f);
}
return;
}
else if (_roundState.equals(RoundState.STARTED))
{
_roundState = RoundState.FIGHTING;
UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 40, 0);
for (Arena a : _gameArenaSet)
{
if (a.getState() != ArenaState.FIGHTING)
continue;
for (Player p : a.getPastPlayers())
{
UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p);
p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f);
}
}
for (Player p : GetPlayers(false))
{
UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p);
p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f);
}
for (Player p : UtilServer.getPlayers())
p.playSound(p.getLocation(), Sound.NOTE_PLING, 2f, 2f);
return;
}
}
@ -993,4 +1005,11 @@ public class Gladiators extends SoloGame
}
}
}
@EventHandler
public void tutorialDie(EntityDeathEvent e)
{
e.getDrops().clear();
e.setDroppedExp(0);
}
}

View File

@ -44,7 +44,7 @@ public class UntouchableTracker extends StatTracker<Gladiators>
for (Player p : getGame().GetPlayers(true))
{
if (_noWin.contains(p.getName()))
return;
continue;
addStat(p, "Untouchable", 1, false, false);
}

View File

@ -2,7 +2,9 @@ package nautilus.game.arcade.game.games.gladiators.tutorial;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Golem;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
import nautilus.game.arcade.ArcadeManager;
@ -20,8 +22,11 @@ public class TutorialGladiators extends GameTutorial
private Gladiators _host;
private Location _pink, _orange;
private Zombie _zombie1, _zombie2;
private Location _pink, _orange, _purple;
private Zombie _zombie;
private Golem _villager;
private boolean _particleStage;
private boolean hasHit1, hasHit2;
@ -36,6 +41,8 @@ public class TutorialGladiators extends GameTutorial
hasHit1 = false;
hasHit2 = false;
_particleStage = false;
_host = (Gladiators) manager.GetGame();
}
@ -59,24 +66,24 @@ public class TutorialGladiators extends GameTutorial
_orange = orange;
}
public Zombie getZombie1()
public Zombie getZombie()
{
return _zombie1;
return _zombie;
}
public void setZombie1(Zombie zombie1)
public void setZombie(Zombie zombie)
{
_zombie1 = zombie1;
_zombie = zombie;
}
public Zombie getZombie2()
public Golem getVillager()
{
return _zombie2;
return _villager;
}
public void setZombie2(Zombie zombie2)
public void setVillager(Golem villager)
{
_zombie2 = zombie2;
_villager = villager;
}
public boolean isHasHit1()
@ -99,6 +106,26 @@ public class TutorialGladiators extends GameTutorial
this.hasHit2 = hasHit2;
}
public Location getPurple()
{
return _purple;
}
public void setPurple(Location purple)
{
_purple = purple;
}
public boolean isParticleStage()
{
return _particleStage;
}
public void setParticleStage(boolean particleStage)
{
_particleStage = particleStage;
}
@Override
public void onEnd()
{
@ -109,11 +136,11 @@ public class TutorialGladiators extends GameTutorial
p.teleport(game.GetTeam(p).GetSpawn().clone());
}
if (_zombie1 != null)
_zombie1.remove();
if (_zombie != null)
_zombie.remove();
if (_zombie2 != null)
_zombie2.remove();
if (_villager != null)
_villager.remove();
Arena gateArena = _host.getArenaByMid(getOrange());
for (Location loc : gateArena.getDoorBlocks())

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.gladiators.tutorial;
import mineplex.core.common.util.C;
import nautilus.game.arcade.gametutorial.TutorialPhase;
import nautilus.game.arcade.gametutorial.TutorialText;
@ -10,12 +11,14 @@ import nautilus.game.arcade.gametutorial.TutorialText;
public class TutorialPhaseGladiators extends TutorialPhase
{
private static final TutorialText TUT1 = new TutorialText(C.cGreen + "Defeat your opponent!", 20 * 3, 1);
private static final TutorialText TUT2 = new TutorialText("", 20 * 4, 2);
private static final TutorialText TUT3 = new TutorialText(C.cGreen + "To the next arena!", C.cGreen + "Follow the particles", 20 * 3, 3);
public TutorialPhaseGladiators()
{
super(new TutorialText[]{
new TutorialText("Defeat your opponent!", 20 * 4, 1),
new TutorialText("", 20 * 2, 2),
new TutorialText("To the next arena!", "Follow the particles", 20 * 4, 3)
TUT1, TUT2, TUT3
});
}
@ -24,4 +27,13 @@ public class TutorialPhaseGladiators extends TutorialPhase
{
return 1;
}
@Override
public void onMessageDisplay(TutorialText text)
{
if (text.equals(TUT3))
{
((TutorialGladiators)getTutorial()).setParticleStage(true);
}
}
}