Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigZombie.java

128 lines
3.9 KiB
Java
Raw Normal View History

2014-01-18 02:34:24 +01:00
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<Player> _active = new HashSet<Player>();
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);
2014-01-18 02:34:24 +01:00
//Disguise
DisguisePig disguise = new DisguisePig(player);
2014-03-19 07:51:37 +01:00
if (Manager.GetGame().GetTeam(player) != null)
disguise.SetName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());
else
disguise.SetName(player.getName());
2014-01-18 02:34:24 +01:00
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);
2014-03-19 07:51:37 +01:00
if (Manager.GetGame().GetTeam(player) != null)
disguise.SetName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());
else
disguise.SetName(player.getName());
2014-01-18 02:34:24 +01:00
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());
}
}