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;
|
2013-09-11 04:22:55 +02:00
|
|
|
import mineplex.core.common.util.NautHashMap;
|
2013-08-29 08:13:05 +02:00
|
|
|
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;
|
2013-09-11 04:22:55 +02:00
|
|
|
private int _maxUses;
|
|
|
|
|
|
|
|
private NautHashMap<String, Integer> _uses = new NautHashMap<String, Integer>();
|
2013-08-29 08:13:05 +02:00
|
|
|
|
|
|
|
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;
|
2013-09-11 04:22:55 +02:00
|
|
|
_maxUses = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PerkLeap(String name, double power, double heightLimit, long recharge, int uses)
|
|
|
|
{
|
|
|
|
super("Leaper", new String[]
|
|
|
|
{
|
|
|
|
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + name + C.cGray + " (" + C.cWhite + uses + " Charges" + C.cGray + ")"
|
|
|
|
});
|
|
|
|
|
|
|
|
_name = name;
|
|
|
|
_power = power;
|
|
|
|
_heightMax = heightLimit;
|
|
|
|
_recharge = recharge;
|
|
|
|
_maxUses = uses;
|
2013-08-29 08:13:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@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;
|
|
|
|
|
2013-09-11 04:22:55 +02:00
|
|
|
//Check Uses
|
|
|
|
if (_maxUses > 0)
|
|
|
|
{
|
|
|
|
if (!_uses.containsKey(player.getName()))
|
|
|
|
_uses.put(player.getName(), _maxUses);
|
|
|
|
|
|
|
|
if (_uses.get(player.getName()) <= 0)
|
|
|
|
{
|
|
|
|
UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(_name) + " anymore."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Energy
|
2013-08-29 08:13:05 +02:00
|
|
|
if (!Recharge.Instance.use(player, _name, _recharge, true))
|
|
|
|
return;
|
|
|
|
|
2013-09-11 04:22:55 +02:00
|
|
|
//Use Use
|
|
|
|
if (_maxUses > 0)
|
|
|
|
{
|
|
|
|
int count = _uses.get(player.getName());
|
|
|
|
count--;
|
|
|
|
|
|
|
|
player.setExp(Math.min(0.99f, (float)count/(float)_maxUses));
|
|
|
|
|
|
|
|
_uses.put(player.getName(), count);
|
|
|
|
}
|
|
|
|
|
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-09-17 02:37:45 +02:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|