87 lines
2.0 KiB
Java
87 lines
2.0 KiB
Java
package nautilus.game.arcade.kit.perks;
|
|
|
|
import org.bukkit.Effect;
|
|
import org.bukkit.GameMode;
|
|
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.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;
|
|
|
|
public PerkDoubleJump(String name, double power, double heightLimit, boolean control)
|
|
{
|
|
super("Jumper", new String[]
|
|
{
|
|
C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name
|
|
});
|
|
|
|
_power = power;
|
|
_heightMax = heightLimit;
|
|
_control = control;
|
|
}
|
|
|
|
@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);
|
|
}
|
|
|
|
@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 (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
|
player.setAllowFlight(true);
|
|
}
|
|
}
|
|
}
|