@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { Player p = event.getPlayer(); if (FlyingPlayer.isFlying(p)) { event.setCancelled(p.getGameMode() != GameMode.CREATIVE); } }
@EventHandler public void doubleJump(PlayerToggleFlightEvent event) { final Player player = event.getPlayer(); if (event.isFlying() && FOPM_TFM_Util.isDoubleJumper(player)) { player.setFlying(false); Vector jump = player.getLocation().getDirection().multiply(2).setY(1.1); player.setVelocity(player.getVelocity().add(jump)); event.setCancelled(true); } }
@EventHandler public void onPlayerFlying(PlayerToggleFlightEvent event) { if (dEntity.isNPC(event.getPlayer())) { return; } state = event.isFlying(); cancelled = event.isCancelled(); this.event = event; fire(); event.setCancelled(cancelled); }
@Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String cmd = CoreUtilities.getXthArg(1, lower); if (cmd.equals("starts") && !state) { return false; } if (cmd.equals("stops") && state) { return false; } return runInCheck(scriptContainer, s, lower, event.getPlayer().getLocation()); }
@EventHandler public void onPlayerStopFlying(PlayerToggleFlightEvent e) { Player p = e.getPlayer(); if (ArenaManager.isPlayerPlaying(p) && ArenaManager.getPlayersArena(p).getState() == Arena.ArenaState.INGAME) { if (!e.isFlying()) { e.setCancelled(true); p.setFlying(true); } } }
@EventHandler public static void onFly(PlayerToggleFlightEvent event) { Player p = event.getPlayer(); if (p.getGameMode() != GameMode.CREATIVE && event.isFlying()) { event.setCancelled(true); Vector jump = p.getLocation().getDirection().multiply(0.4).setY(1.1); p.setVelocity(p.getVelocity().add(jump)); p.setAllowFlight(false); p.setFallDistance(1); p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 100, 1); ParticleEffect.CLOUD.display(1, 1, 1, 1, 20, p.getLocation(), 20); } }
@EventHandler public void onFly(PlayerToggleFlightEvent e) { final Player p = e.getPlayer(); Runnable jump2 = new Runnable() { public void run() { p.setLevel(2); p.setFallDistance(-100); } }; Runnable jump1 = new Runnable() { public void run() { p.setLevel(1); p.setFallDistance(-100); } }; Runnable jump = new Runnable() { public void run() { p.setAllowFlight(true); p.setFlying(false); p.setLevel(0); p.setFallDistance(-100); } }; if (p.getGameMode().equals(GameMode.ADVENTURE) && e.isFlying() == true) { p.setFlying(false); p.setAllowFlight(false); p.setLevel(3); for (Player all : Bukkit.getOnlinePlayers()) { all.playSound(p.getLocation(), Sound.WITHER_SHOOT, 0.1f, 0.1f); } p.setVelocity(p.getLocation().getDirection().multiply(3).setY(p.getVelocity().getY() + 1.5)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, jump2, 20L); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, jump1, 40L); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, jump, 60L); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onFly(PlayerToggleFlightEvent tfe) { Player p = tfe.getPlayer(); Game g = Main.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); }
@Override public ScriptEntryData getScriptEntryData() { return new BukkitScriptEntryData( dEntity.isPlayer(event.getPlayer()) ? dEntity.getPlayerFrom(event.getPlayer()) : null, null); }