2013-08-29 08:13:05 +02:00
|
|
|
package nautilus.game.arcade.kit.perks;
|
|
|
|
|
|
|
|
import org.bukkit.Effect;
|
2013-09-04 03:55:19 +02:00
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.Horse;
|
2013-08-29 08:13:05 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.block.Action;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.F;
|
|
|
|
import mineplex.core.common.util.UtilAction;
|
|
|
|
import mineplex.core.common.util.UtilBlock;
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
|
|
|
import nautilus.game.arcade.kit.Perk;
|
|
|
|
import nautilus.game.arcade.kit.perks.event.PerkLeapEvent;
|
|
|
|
|
|
|
|
public class PerkLeap extends Perk
|
|
|
|
{
|
|
|
|
private String _name;
|
|
|
|
private double _power;
|
|
|
|
private double _heightMax;
|
|
|
|
private long _recharge;
|
|
|
|
|
|
|
|
public PerkLeap(String name, double power, double heightLimit, long recharge)
|
|
|
|
{
|
|
|
|
super("Leaper", new String[]
|
|
|
|
{
|
|
|
|
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + name
|
|
|
|
});
|
|
|
|
|
|
|
|
_name = name;
|
|
|
|
_power = power;
|
|
|
|
_heightMax = heightLimit;
|
|
|
|
_recharge = recharge;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 (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, _name, _recharge, true))
|
|
|
|
return;
|
|
|
|
|
2013-09-04 03:55:19 +02:00
|
|
|
Entity ent = player;
|
|
|
|
|
|
|
|
if (player.getVehicle() != null)
|
|
|
|
if (player.getVehicle() instanceof Horse)
|
|
|
|
ent = player.getVehicle();
|
|
|
|
|
|
|
|
UtilAction.velocity(ent, _power, 0.2, _heightMax, true);
|
2013-08-29 08:13:05 +02:00
|
|
|
player.setFallDistance(0);
|
|
|
|
|
|
|
|
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(_name) + "."));
|
|
|
|
|
|
|
|
player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0);
|
|
|
|
|
|
|
|
PerkLeapEvent leapEvent = new PerkLeapEvent(player);
|
|
|
|
UtilServer.getServer().getPluginManager().callEvent(leapEvent);
|
|
|
|
}
|
|
|
|
}
|