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

84 lines
2.2 KiB
Java
Raw Normal View History

2013-08-29 08:13:05 +02:00
package nautilus.game.arcade.kit.perks;
import org.bukkit.Effect;
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;
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);
}
}