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

92 lines
2.1 KiB
Java
Raw Normal View History

2013-08-29 08:13:05 +02:00
package nautilus.game.arcade.kit.perks;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Effect;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.data.IcePathData;
public class PerkIcePath extends Perk
{
private HashSet<IcePathData> _data = new HashSet<IcePathData>();
public PerkIcePath()
{
super("Ice Path", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Ice Path"
});
}
@EventHandler
public void Skill(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 1000, true))
return;
player.setVelocity(new Vector(0,0,0));
player.teleport(player.getLocation().add(0, 0.5, 0));
_data.add(new IcePathData(player));
}
@EventHandler
public void Freeze(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<IcePathData> dataIterator = _data.iterator();
while (dataIterator.hasNext())
{
IcePathData data = dataIterator.next();
Block block = data.GetNextBlock();
if (block == null)
{
dataIterator.remove();
}
else
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 79);
Manager.GetBlockRestore().Add(block, 79, (byte)0, 6000);
}
}
}
}