2014-10-24 10:05:57 +02:00
|
|
|
package nautilus.game.arcade.kit.perks;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
import org.bukkit.DyeColor;
|
|
|
|
import org.bukkit.Effect;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.Horse;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.block.Action;
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.F;
|
|
|
|
import mineplex.core.common.util.UtilAction;
|
|
|
|
import mineplex.core.common.util.UtilEnt;
|
|
|
|
import mineplex.core.common.util.UtilMath;
|
|
|
|
import mineplex.core.common.util.UtilParticle;
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
2015-05-03 23:37:00 +02:00
|
|
|
import mineplex.core.common.util.UtilServer;
|
2014-10-24 10:05:57 +02:00
|
|
|
import mineplex.core.common.util.UtilTime;
|
|
|
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
2015-05-03 23:37:00 +02:00
|
|
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
2014-10-24 10:05:57 +02:00
|
|
|
import mineplex.core.disguise.disguises.DisguiseBase;
|
|
|
|
import mineplex.core.disguise.disguises.DisguiseSheep;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
|
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
|
|
import nautilus.game.arcade.kit.Perk;
|
|
|
|
|
|
|
|
public class PerkWoolCloud extends Perk
|
|
|
|
{
|
|
|
|
private HashMap<Player, Long> _active = new HashMap<Player, Long>();
|
|
|
|
|
|
|
|
public PerkWoolCloud()
|
|
|
|
{
|
|
|
|
super("Wooly Rocket", new String[]
|
|
|
|
{
|
|
|
|
C.cYellow + "Right-Click" + C.cGray + " with Spade to " + C.cGreen + "Wooly Rocket"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void Leap(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
if (event.isCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.getPlayer().getItemInHand() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!event.getPlayer().getItemInHand().getType().toString().contains("_SPADE"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Recharge
|
2014-10-31 00:35:47 +01:00
|
|
|
if (!Recharge.Instance.use(player, GetName(), 10000, true, true))
|
2014-10-24 10:05:57 +02:00
|
|
|
return;
|
|
|
|
|
2014-10-31 00:35:47 +01:00
|
|
|
UtilAction.velocity(player, new Vector(0,1,0), 1, false, 0, 0, 2, true);
|
2014-10-24 10:05:57 +02:00
|
|
|
|
|
|
|
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + "."));
|
|
|
|
|
|
|
|
player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0);
|
|
|
|
|
|
|
|
//Allow double jump
|
|
|
|
player.setAllowFlight(true);
|
|
|
|
|
|
|
|
setWoolColor(player, DyeColor.RED);
|
|
|
|
|
|
|
|
_active.put(player, System.currentTimeMillis());
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void update(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.TICK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Iterator<Player> playerIterator = _active.keySet().iterator();
|
|
|
|
while (playerIterator.hasNext())
|
|
|
|
{
|
|
|
|
Player player = playerIterator.next();
|
|
|
|
|
2015-05-03 23:37:00 +02:00
|
|
|
UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 4,
|
|
|
|
ViewDist.LONGER, UtilServer.getPlayers());
|
2014-10-24 10:05:57 +02:00
|
|
|
|
|
|
|
if (!UtilTime.elapsed(_active.get(player), 200))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (Player other : Manager.GetGame().GetPlayers(true))
|
|
|
|
{
|
|
|
|
if (player.equals(other))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (UtilMath.offset(player, other) < 2)
|
|
|
|
{
|
|
|
|
//Damage Event
|
|
|
|
Manager.GetDamage().NewDamageEvent(other, player, null,
|
|
|
|
DamageCause.CUSTOM, 8, true, false, false,
|
|
|
|
player.getName(), GetName());
|
|
|
|
|
2015-05-03 23:37:00 +02:00
|
|
|
UtilParticle.PlayParticle(ParticleType.EXPLODE, other.getLocation(), 0f, 0f, 0f, 0, 1,
|
|
|
|
ViewDist.MAX, UtilServer.getPlayers());
|
|
|
|
UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 10,
|
|
|
|
ViewDist.MAX, UtilServer.getPlayers());
|
2014-10-24 10:05:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UtilEnt.isGrounded(player) || UtilTime.elapsed(_active.get(player), 1200))
|
|
|
|
{
|
|
|
|
playerIterator.remove();
|
|
|
|
setWoolColor(player, DyeColor.WHITE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setWoolColor(Player player, DyeColor color)
|
|
|
|
{
|
|
|
|
DisguiseBase disguise = Manager.GetDisguise().getDisguise(player);
|
|
|
|
if (disguise != null && disguise instanceof DisguiseSheep)
|
|
|
|
{
|
|
|
|
DisguiseSheep sheep = (DisguiseSheep)disguise;
|
|
|
|
sheep.setSheared(false);
|
|
|
|
sheep.setColor(color);
|
|
|
|
|
|
|
|
sheep.UpdateDataWatcher();
|
|
|
|
Manager.GetDisguise().updateDisguise(disguise);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void knockback(CustomDamageEvent event)
|
|
|
|
{
|
|
|
|
if (event.GetReason() == null || !event.GetReason().contains(GetName()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
event.AddKnockback(GetName(), 2.5);
|
|
|
|
}
|
|
|
|
}
|