@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); }
@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); } }