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; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseCreeper; 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; //Chicken Cancel DisguiseBase disguise = Manager.GetDisguise().getDisguise(player); if (disguise != null && disguise instanceof DisguiseChicken) return; 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); } } } }