b00fb0952a
Fixed fissure not working on slabs Fixed a bug in recharge Added ability for admins to give other people creative (they lose it when the admin quits)
121 lines
2.9 KiB
Java
121 lines
2.9 KiB
Java
package nautilus.game.arcade.kit.perks;
|
|
|
|
import org.bukkit.Effect;
|
|
import org.bukkit.GameMode;
|
|
import org.bukkit.Material;
|
|
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;
|
|
import mineplex.core.recharge.Recharge;
|
|
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;
|
|
private long _recharge;
|
|
private boolean _displayForce;
|
|
|
|
public PerkDoubleJump(String name, double power, double heightLimit, boolean control)
|
|
{
|
|
super(name, new String[]
|
|
{
|
|
C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name
|
|
});
|
|
|
|
_power = power;
|
|
_heightMax = heightLimit;
|
|
_control = control;
|
|
_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;
|
|
}
|
|
|
|
@EventHandler
|
|
public void FlightHop(PlayerToggleFlightEvent event)
|
|
{
|
|
Player player = event.getPlayer();
|
|
|
|
if (!Kit.HasKit(player))
|
|
return;
|
|
|
|
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);
|
|
|
|
//Recharge
|
|
if (_recharge > 0)
|
|
{
|
|
Recharge.Instance.useForce(player, GetName(), _recharge);
|
|
|
|
if (_displayForce)
|
|
{
|
|
Recharge.Instance.setDisplayForce(player, GetName(), true);
|
|
}
|
|
}
|
|
}
|
|
|
|
@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;
|
|
|
|
if (_recharge > 0 && !Recharge.Instance.usable(player, GetName()))
|
|
continue;
|
|
|
|
if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
|
player.setAllowFlight(true);
|
|
}
|
|
}
|
|
}
|