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;
|
2013-08-31 05:15:16 +02:00
|
|
|
import mineplex.core.common.util.F;
|
2013-08-29 08:13:05 +02:00
|
|
|
import mineplex.core.common.util.UtilBlock;
|
2013-08-31 05:15:16 +02:00
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
2013-08-29 08:13:05 +02:00
|
|
|
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;
|
|
|
|
|
2013-09-09 10:06:44 +02:00
|
|
|
if (!Recharge.Instance.use(player, GetName(), 12000, true))
|
2013-08-29 08:13:05 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
player.setVelocity(new Vector(0,0,0));
|
2013-10-12 00:34:46 +02:00
|
|
|
player.teleport(player.getLocation().add(0, 0.75, 0));
|
2013-08-29 08:13:05 +02:00
|
|
|
|
|
|
|
_data.add(new IcePathData(player));
|
2013-08-31 05:15:16 +02:00
|
|
|
|
|
|
|
//Inform
|
|
|
|
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
|
2013-08-29 08:13:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|