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;
|
2015-01-30 01:08:23 +01:00
|
|
|
import nautilus.game.arcade.kit.SmashPerk;
|
2014-01-18 02:34:24 +01:00
|
|
|
|
2015-01-30 01:08:23 +01:00
|
|
|
public class PerkPigZombie extends SmashPerk
|
2014-01-18 02:34:24 +01:00
|
|
|
{
|
|
|
|
public HashSet<Player> _active = new HashSet<Player>();
|
|
|
|
|
|
|
|
public PerkPigZombie()
|
|
|
|
{
|
|
|
|
super("Nether Pig", new String[]
|
|
|
|
{
|
2015-01-29 01:54:59 +01:00
|
|
|
C.cGray + "Become Nether Pig when HP is below 6.",
|
|
|
|
C.cGray + "Return to Pig when HP is 10 or higher."
|
2014-01-18 02:34:24 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
2015-01-30 01:08:23 +01:00
|
|
|
if (player.getHealth() < 10 || isSuperActive(player))
|
2014-01-18 02:34:24 +01:00
|
|
|
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));
|
|
|
|
|
2014-09-17 03:18:59 +02:00
|
|
|
player.getInventory().remove(Material.IRON_HELMET);
|
|
|
|
player.getInventory().remove(Material.IRON_CHESTPLATE);
|
|
|
|
player.getInventory().remove(Material.IRON_LEGGINGS);
|
|
|
|
player.getInventory().remove(Material.IRON_BOOTS);
|
2014-03-13 06:32:48 +01:00
|
|
|
|
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)
|
2014-12-16 03:46:14 +01:00
|
|
|
disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());
|
2014-03-19 07:51:37 +01:00
|
|
|
else
|
2014-12-16 03:46:14 +01:00
|
|
|
disguise.setName(player.getName());
|
2014-03-19 07:51:37 +01:00
|
|
|
|
2014-12-16 03:46:14 +01:00
|
|
|
disguise.setCustomNameVisible(true);
|
2014-01-18 02:34:24 +01:00
|
|
|
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
|
|
|
|
{
|
2015-01-30 01:08:23 +01:00
|
|
|
if (player.getHealth() <= 0 || (!isSuperActive(player) && player.getHealth() > 6))
|
2014-01-18 02:34:24 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
//Activate
|
|
|
|
_active.add(player);
|
|
|
|
|
|
|
|
//Armor
|
2014-09-17 03:18:59 +02:00
|
|
|
player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET));
|
|
|
|
player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
|
|
|
|
player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
|
|
|
|
player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
|
2014-01-18 02:34:24 +01:00
|
|
|
|
|
|
|
//Disguise
|
|
|
|
DisguisePigZombie disguise = new DisguisePigZombie(player);
|
2014-03-19 07:51:37 +01:00
|
|
|
|
|
|
|
if (Manager.GetGame().GetTeam(player) != null)
|
2014-12-16 03:46:14 +01:00
|
|
|
disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());
|
2014-03-19 07:51:37 +01:00
|
|
|
else
|
2014-12-16 03:46:14 +01:00
|
|
|
disguise.setName(player.getName());
|
2014-03-19 07:51:37 +01:00
|
|
|
|
2014-12-16 03:46:14 +01:00
|
|
|
disguise.setCustomNameVisible(true);
|
2014-01-18 02:34:24 +01:00
|
|
|
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") + "."));
|
2015-01-29 01:54:59 +01:00
|
|
|
|
|
|
|
player.setExp(0.99f);
|
2014-01-18 02:34:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void Clean(PlayerDeathEvent event)
|
|
|
|
{
|
|
|
|
_active.remove(event.getEntity());
|
|
|
|
}
|
|
|
|
}
|