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 _data = new HashSet(); 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 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); } } } }