2013-09-18 11:46:45 +02:00
|
|
|
package mineplex.hub.modules;
|
|
|
|
|
|
|
|
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 org.bukkit.util.Vector;
|
|
|
|
|
|
|
|
import mineplex.core.MiniPlugin;
|
|
|
|
import mineplex.core.common.util.F;
|
|
|
|
import mineplex.core.common.util.UtilAction;
|
|
|
|
import mineplex.core.common.util.UtilBlock;
|
|
|
|
import mineplex.core.common.util.UtilEnt;
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
2014-08-06 03:07:49 +02:00
|
|
|
import mineplex.core.disguise.disguises.DisguiseBase;
|
|
|
|
import mineplex.core.disguise.disguises.DisguiseChicken;
|
|
|
|
import mineplex.core.disguise.disguises.DisguiseCreeper;
|
2013-09-18 11:46:45 +02:00
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
|
|
import mineplex.hub.HubManager;
|
|
|
|
|
|
|
|
public class JumpManager extends MiniPlugin
|
|
|
|
{
|
|
|
|
public HubManager Manager;
|
|
|
|
|
|
|
|
public JumpManager(HubManager manager)
|
|
|
|
{
|
|
|
|
super("Double Jump", manager.GetPlugin());
|
|
|
|
|
|
|
|
Manager = manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void FlightHop(PlayerToggleFlightEvent event)
|
|
|
|
{
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (player.getGameMode() == GameMode.CREATIVE)
|
|
|
|
return;
|
2014-08-06 03:07:49 +02:00
|
|
|
|
|
|
|
//Chicken Cancel
|
|
|
|
DisguiseBase disguise = Manager.GetDisguise().getDisguise(player);
|
|
|
|
if (disguise != null && disguise instanceof DisguiseChicken)
|
|
|
|
return;
|
|
|
|
|
2013-09-18 11:46:45 +02:00
|
|
|
event.setCancelled(true);
|
|
|
|
player.setFlying(false);
|
|
|
|
|
|
|
|
//Disable Flight
|
|
|
|
player.setAllowFlight(false);
|
|
|
|
|
|
|
|
//Parkour Disable
|
|
|
|
if (Manager.GetParkour().InParkour(player))
|
|
|
|
{
|
|
|
|
UtilPlayer.message(player, F.main("Parkour", "You cannot Double Jump near Parkour Challenges."));
|
|
|
|
player.setVelocity(new Vector(0,0,0));
|
|
|
|
player.teleport(player.getLocation());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Velocity
|
|
|
|
UtilAction.velocity(player, 1.4, 0.2, 1, true);
|
|
|
|
|
|
|
|
//Sound
|
|
|
|
player.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 (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
|
|
|
{
|
|
|
|
player.setAllowFlight(true);
|
|
|
|
player.setFlying(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|