package nautilus.game.arcade.kit.perks; 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.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; Entity ent = player; if (player.getVehicle() != null) if (player.getVehicle() instanceof Horse) ent = player.getVehicle(); UtilAction.velocity(ent, _power, 0.2, _heightMax, true); 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); } }