package nautilus.game.arcade.kit.perks; import java.util.HashSet; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.disguise.disguises.DisguisePig; import mineplex.core.disguise.disguises.DisguisePigZombie; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.kit.Perk; public class PerkPigZombie extends Perk { public HashSet _active = new HashSet(); public PerkPigZombie() { super("Nether Pig", new String[] { C.cGray + "Become Nether Pig when HP is below 4.", C.cGray + "Return to Pig when HP is above 6." }); } @EventHandler public void Check(UpdateEvent event) { if (event.getType() != UpdateType.FASTER) return; for (Player player : Manager.GetGame().GetPlayers(true)) { if (!Kit.HasKit(player)) continue; //Active if (_active.contains(player)) { Manager.GetCondition().Factory().Speed("Pig Zombie", player, player, 0.9, 0, false, false, false); if (player.getHealth() < 8) continue; //Deactivate _active.remove(player); //Armor player.getInventory().setHelmet(null); player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE)); player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS)); player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS)); player.getInventory().remove(Material.DIAMOND_HELMET); player.getInventory().remove(Material.DIAMOND_CHESTPLATE); player.getInventory().remove(Material.DIAMOND_LEGGINGS); player.getInventory().remove(Material.DIAMOND_BOOTS); //Disguise DisguisePig disguise = new DisguisePig(player); if (Manager.GetGame().GetTeam(player) != null) disguise.SetName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); else disguise.SetName(player.getName()); disguise.SetCustomNameVisible(true); Manager.GetDisguise().disguise(disguise); //Sound player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 2f, 1f); player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 2f, 1f); //Inform UtilPlayer.message(player, F.main("Skill", "You returned to " + F.skill("Pig Form") + ".")); } //Not Active else { if (player.getHealth() <= 0 || player.getHealth() > 4) continue; //Activate _active.add(player); //Armor player.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); player.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); player.getInventory().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); player.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); //Disguise DisguisePigZombie disguise = new DisguisePigZombie(player); if (Manager.GetGame().GetTeam(player) != null) disguise.SetName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); else disguise.SetName(player.getName()); disguise.SetCustomNameVisible(true); Manager.GetDisguise().disguise(disguise); //Sound player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_PIG_ANGRY, 2f, 1f); player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_PIG_ANGRY, 2f, 1f); //Inform UtilPlayer.message(player, F.main("Skill", "You transformed into " + F.skill("Nether Pig Form") + ".")); } } } @EventHandler public void Clean(PlayerDeathEvent event) { _active.remove(event.getEntity()); } }