Java Code Examples for org.bukkit.event.player.PlayerToggleFlightEvent#getPlayer()
The following examples show how to use
org.bukkit.event.player.PlayerToggleFlightEvent#getPlayer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoubleJumpMatchModule.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerToggleFlight(final PlayerToggleFlightEvent event) { Player player = event.getPlayer(); Jumper jumper = this.jumpers.get(player); if (jumper == null) return; if (event.isFlying()) { event.setCancelled(true); this.setCharge(jumper, 0f); this.refreshJump(player); // calculate jump Vector impulse = player.getLocation().getDirection(); impulse.setY(0.75 + Math.abs(impulse.getY()) * 0.5); impulse.multiply(jumper.kit.power / 3f); event.getPlayer().setVelocity(impulse); player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_INFECT, 0.5f, 1.8f); } }
Example 2
Source File: DoubleJumpMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerToggleFlight(final PlayerToggleFlightEvent event) { Player player = event.getPlayer(); Jumper jumper = this.jumpers.get(player); if(jumper == null) return; if(event.isFlying()) { event.setCancelled(true); this.setCharge(jumper, 0f); this.refreshJump(player); // calculate jump Vector impulse = player.getLocation().getDirection(); impulse.setY(0.75 + Math.abs(impulse.getY()) * 0.5); impulse.multiply(jumper.kit.power / 3f); event.getPlayer().applyImpulse(impulse, true); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f); } }
Example 3
Source File: Acrobat.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void AcrobatDoubleJump(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); if(player.getGameMode() != GameMode.CREATIVE) { AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(Game.isGameRunning() && p != null && p.getKit().equals(this)) { Delays.getInstance().addDelay(player, System.currentTimeMillis()+10000, this.getInternalName()); event.setCancelled(true); player.setAllowFlight(false); player.setFlying(false); player.setVelocity(player.getLocation().getDirection().setY(1).multiply(1)); player.playSound(player.getLocation(), Sound.ZOMBIE_INFECT, 1.0F, 2.0F); } else { player.setAllowFlight(false); player.setFlying(false); } } }
Example 4
Source File: PlayerListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onFly(PlayerToggleFlightEvent tfe) { Player p = tfe.getPlayer(); Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p); if (g == null) { return; } if (g.getState() == GameState.STOPPED) { return; } if (g.getState() == GameState.RUNNING && g.isSpectator(p)) { tfe.setCancelled(false); return; } tfe.setCancelled(true); }
Example 5
Source File: DoubleJump.java From HubBasics with GNU Lesser General Public License v3.0 | 6 votes |
@EventHandler public void onJump(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); if (player.getGameMode() == GameMode.CREATIVE) return; if (!isEnabledInWorld(player.getWorld())) return; Section section = getWorldConfiguration(player.getWorld().getName()); event.setCancelled(true); player.setAllowFlight(false); player.setFlying(false); Sound sound = FinderUtil.findSound(section.getString("Sound", "NOPE")); player.setVelocity(player.getLocation().getDirection().multiply(section.getDouble("Force", 1.0)).setY(1)); if (sound != null) { player.playSound(player.getLocation(), sound, 1.0F, -5.0F); } }
Example 6
Source File: DoubleJumpKit.java From CardinalPGM with MIT License | 6 votes |
@EventHandler public void onPlayerToggleFly(PlayerToggleFlightEvent event) { if (!enabled) return; Player player = event.getPlayer(); if (!players.contains(player.getUniqueId()) || player.getExp() > 1.0f || !event.isFlying()) return; player.setAllowFlight(false); player.setExp(0.0f); event.setCancelled(true); Vector normal = player.getEyeLocation().getDirection(); normal.setY(0.75 + Math.max(normal.getY() * 0.5, 0)); normal.multiply(power / 2); event.getPlayer().setVelocity(normal); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f); update(); }
Example 7
Source File: DoubleJumpFeature.java From VoxelGamesLibv2 with MIT License | 5 votes |
@GameEvent public void e(@Nonnull PlayerToggleFlightEvent event) { final Player player = event.getPlayer(); if (player.getGameMode() != GameMode.CREATIVE) { if (!disabled.contains(player.getUniqueId())) { event.setCancelled(true); player.setAllowFlight(false); player.setFlying(false); player.setVelocity(player.getLocation().getDirection().multiply(1.6).setY(1)); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_FLAP, 4, 1); } } }
Example 8
Source File: ListenerFlight.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true) public void onToggleFlight(PlayerToggleFlightEvent e) { if(!e.isFlying()) return; FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml"); if(!config.getBoolean("flight.prevent-flying")) return; Player player = e.getPlayer(); ICombatManager manager = this.plugin.getCombatManager(); if(!manager.isInCombat(player)) return; e.setCancelled(true); String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.flight.no-flying"); this.plugin.sendMessage(player, message); }