2013-08-27 17:14:08 +02:00
|
|
|
package nautilus.game.arcade.kit.perks;
|
|
|
|
|
|
|
|
import org.bukkit.Effect;
|
|
|
|
import org.bukkit.GameMode;
|
2014-11-05 01:26:39 +01:00
|
|
|
import org.bukkit.Material;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
|
|
|
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.UtilAction;
|
|
|
|
import mineplex.core.common.util.UtilBlock;
|
|
|
|
import mineplex.core.common.util.UtilEnt;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
2014-11-05 01:26:39 +01:00
|
|
|
import mineplex.core.recharge.Recharge;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
|
|
import nautilus.game.arcade.kit.Perk;
|
|
|
|
|
|
|
|
public class PerkDoubleJump extends Perk
|
|
|
|
{
|
|
|
|
private double _power;
|
|
|
|
private double _heightMax;
|
|
|
|
private boolean _control;
|
2014-11-05 01:26:39 +01:00
|
|
|
private long _recharge;
|
|
|
|
private boolean _displayForce;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
public PerkDoubleJump(String name, double power, double heightLimit, boolean control)
|
|
|
|
{
|
2014-11-05 01:26:39 +01:00
|
|
|
super(name, new String[]
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name
|
|
|
|
});
|
|
|
|
|
|
|
|
_power = power;
|
|
|
|
_heightMax = heightLimit;
|
|
|
|
_control = control;
|
2014-11-05 01:26:39 +01:00
|
|
|
_recharge = 0;
|
|
|
|
_displayForce = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PerkDoubleJump(String name, double power, double heightLimit, boolean control, long recharge, boolean displayForce)
|
|
|
|
{
|
|
|
|
super(name, new String[]
|
|
|
|
{
|
|
|
|
C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name
|
|
|
|
});
|
|
|
|
|
|
|
|
_power = power;
|
|
|
|
_heightMax = heightLimit;
|
|
|
|
_control = control;
|
|
|
|
_recharge = recharge;
|
|
|
|
_displayForce = displayForce;
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void FlightHop(PlayerToggleFlightEvent event)
|
|
|
|
{
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
2013-08-29 08:13:05 +02:00
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
return;
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (player.getGameMode() == GameMode.CREATIVE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
player.setFlying(false);
|
|
|
|
|
|
|
|
//Disable Flight
|
|
|
|
player.setAllowFlight(false);
|
|
|
|
|
|
|
|
//Velocity
|
|
|
|
if (_control)
|
|
|
|
{
|
|
|
|
UtilAction.velocity(player, _power, 0.2, _heightMax, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UtilAction.velocity(player, player.getLocation().getDirection(), _power, true, _power, 0, _heightMax, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Sound
|
|
|
|
player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0);
|
2014-11-05 01:26:39 +01:00
|
|
|
|
|
|
|
//Recharge
|
|
|
|
if (_recharge > 0)
|
|
|
|
{
|
|
|
|
Recharge.Instance.useForce(player, GetName(), _recharge);
|
|
|
|
|
|
|
|
if (_displayForce)
|
|
|
|
{
|
|
|
|
Recharge.Instance.setDisplayForce(player, GetName(), true);
|
|
|
|
}
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void FlightUpdate(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.TICK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (player.getGameMode() == GameMode.CREATIVE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
continue;
|
|
|
|
|
2014-11-05 01:26:39 +01:00
|
|
|
if (_recharge > 0 && !Recharge.Instance.usable(player, GetName()))
|
|
|
|
continue;
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
|
|
|
player.setAllowFlight(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|