@EventHandler public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { if (!this.allowed.contains(event.getPlayer().getUniqueId())) return; this.allowed.remove(event.getPlayer().getUniqueId()); if (this.hub.getPlayerManager().isBusy(event.getPlayer())) return; event.setCancelled(true); event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection().multiply(1.6D).setY(1.0D)); event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 1.0F, 1.0F); for (int i = 0; i < 20; i++) ParticleEffect.CLOUD.display(0.5F, 0.15F, 0.5F, 0.25F, 20, event.getPlayer().getLocation().subtract(0.0F, 0.20F, 0.0F)); event.getPlayer().setAllowFlight(false); }
/** * Keeps track of player glide; if they are gliding we track when they glided, or, clear if no longer gliding. * * @param event * the flying toggle event */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void toggleGlideEvent(PlayerToggleFlightEvent event) { if (event.isFlying()) { glidingSince.computeIfAbsent(event.getPlayer().getUniqueId(), u -> { //if (event.getPlayer().hasPermission("addgun.data")) { event.getPlayer().sendMessage(ChatColor.GOLD + "glide started"); } return System.currentTimeMillis(); }); glidingEnd.remove(event.getPlayer().getUniqueId()); } else { /*if (glidingSince.containsKey(event.getPlayer().getUniqueId()) && event.getPlayer().hasPermission("addgun.data")) { event.getPlayer().sendMessage(ChatColor.GOLD + " glide cleared"); }*/ glidingSince.remove(event.getPlayer().getUniqueId()); glidingEnd.computeIfAbsent(event.getPlayer().getUniqueId(), u -> { return System.currentTimeMillis(); }); } }
@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); } }
@EventHandler(ignoreCancelled = true) public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); if(player.isFlying()) return; if(player.hasPermission("gpflags.bypass")) return; Flag flag = this.GetFlagInstanceAtLocation(player.getLocation(), player); if(flag == null) return; GPFlags.sendMessage(player, TextMode.Err, Messages.CantFlyHere); event.setCancelled(true); Location underLocation = player.getLocation().add(0, -1, 0); Material underType = underLocation.getBlock().getType(); if(!underType.isSolid()) player.teleport(underLocation); player.setFallDistance(player.getFallDistance() + 1); }
/** * Cancels the player from flying and adds to the player's velocity. * * @param event The event called. */ @EventHandler public void onPlayerToggleFly(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); UUID id = player.getUniqueId(); KitDoubleJump.DoubleJumpData data = players.get(id); if (data != null && data.isEnabled() && players.containsKey(player.getUniqueId()) && player.getExp() <= 1.0f && event.isFlying()) { 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(data.getPower() / 2); event.getPlayer().setVelocity(normal); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f); } }
@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); } } }
@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); }
@EventHandler public void onPlayerToggleFlight(PlayerToggleFlightEvent e) { this.getJetpackManager().checkJetpackItemForPlayer(e.getPlayer()); JetpackItem item = this.getJetpackManager().getJetpackItemForPlayer(e.getPlayer()); if (item != null) { if (item.isEnabled()) { item.setEnabled(false); } else { item.setEnabled(true); } e.setCancelled(true); } }
@EventHandler() public void flightToggle(PlayerToggleFlightEvent ev) { Player p = ev.getPlayer(); UUID key = p.getUniqueId(); //copy pasta! if (isFlying.contains(key)) { //stop flight and restore state p.setFlying(false); p.setAllowFlight(wasAllowedFlying.contains(key)); if (wasAllowedFlying.contains(key)) { wasAllowedFlying.remove(key); } isFlying.remove(key); } }
public void processPlayerAbilities(C13PacketPlayerAbilities p_147348_1_) { // CraftBukkit start - d() should be isFlying() if (this.playerEntity.capabilities.allowFlying && this.playerEntity.capabilities.isFlying != p_147348_1_.func_149488_d()) { PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.playerEntity), p_147348_1_.func_149488_d()); this.server.getPluginManager().callEvent(event); if (!event.isCancelled()) { this.playerEntity.capabilities.isFlying = p_147348_1_.func_149488_d(); // Actually set the player's flying status } else { this.playerEntity.sendPlayerAbilities(); // Tell the player their ability was reverted } } // CraftBukkit end }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onToggleFlight(PlayerToggleFlightEvent event) { if (event.getPlayer().getGameMode() == GameMode.CREATIVE || !event.getPlayer().hasPermission("doublejump") || event.getPlayer().hasMetadata("DJ_OFF")) return; PlayerDoubleJumpEvent pdje = new PlayerDoubleJumpEvent(event.getPlayer(), power); getServer().getPluginManager().callEvent(pdje); if (pdje.isCancelled()) return; if (ncp != null) { ncp.allowDoubleJump(event.getPlayer()); } event.getPlayer().setAllowFlight(false); event.getPlayer().setFlying(false); event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection() .multiply(2 * pdje.getPower()) .setY(1 * pdje.getPower())); event.setCancelled(true); }
@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(); }
@EventHandler public void onToToggleFlight(PlayerToggleFlightEvent ev) { if(isWatchingTutorial(ev.getPlayer().getUniqueId())) { ev.setCancelled(true); ev.getPlayer().setFlying(true); } }
@EventHandler @SuppressWarnings("all") //sick of intellij giving me unused warnings public void onFlyDisable(PlayerToggleFlightEvent e) { if(e.isFlying()) return; try { Flight.setMovingExempt(e.getPlayer(), this.getClass(),2000); } catch (IllegalAccessException ex) { ex.printStackTrace(); } }
@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_ENDERDRAGON_FLAP, 4, 1); } } }
public void a(PacketPlayInAbilities packetplayinabilities) { // CraftBukkit start if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) { PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying()); this.server.getPluginManager().callEvent(event); if (!event.isCancelled()) { this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually set the player's flying status } else { this.player.updateAbilities(); // Tell the player their ability was reverted } } // CraftBukkit end }
public void onPlayerToggleFlight(PlayerToggleFlightEvent event){ Player player = event.getPlayer(); if ((player.getGameMode() != GameMode.CREATIVE)) { event.setCancelled(true); player.setAllowFlight(false); player.setFlying(false); player.setVelocity(st.giveVector(player.getLocation()).multiply(3)); player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_FIREWORK_LARGE_BLAST, 1.0F, -5.0F); } }
/** * Handles player flight. * @param event The event. */ @EventHandler (priority = EventPriority.HIGH) public void onPlayerToggleFlight (PlayerToggleFlightEvent event) { if (event.getPlayer ().getGameMode () == GameMode.CREATIVE || event.getPlayer ().getGameMode () == GameMode.SPECTATOR) return; event.setCancelled (true); event.getPlayer ().setAllowFlight (false); event.getPlayer ().setVelocity (event.getPlayer ().getLocation ().getDirection ().multiply (1.6d).setY (1.0d)); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommandPreprocessEvent(PlayerToggleFlightEvent event) { if (plugin.isDisabled() || event.getPlayer().hasPermission("antiworldfly.fly")) { return; } if (!this.plugin.isAntiFlyCreative() && event.getPlayer().getGameMode() == GameMode.CREATIVE || "SPECTATOR".equals(event.getPlayer().getGameMode().toString())) { return; } Player player = event.getPlayer(); for (String world : plugin.getAntiFlyWorlds()) { if (event.getPlayer().getWorld().getName().equalsIgnoreCase(world)) { // Disable flying. player.setAllowFlight(false); player.getPlayer().setFlying(false); event.setCancelled(true); if (plugin.isChatMessage()) { player.sendMessage(plugin.getChatHeader() + plugin.getPluginLang().getString("fly-disabled-chat", "Flying is disabled in this world.")); } if (plugin.isTitleMessage()) { try { PacketSender.sendTitlePacket(player, "{\"text\":\"" + plugin.getPluginLang().getString("fly-disabled-title", "&9AntiWorldFly") + "\"}", "{\"text\":\"" + plugin.getPluginLang().getString("fly-disabled-subtitle", "Flying is disabled in this world.") + "\"}"); } catch (Exception e) { plugin.getLogger().log(Level.SEVERE, "Errors while trying to display flying disabled title: ", e); } } break; } } }
public void a(Packet202Abilities packet202abilities) { // CraftBukkit start if (this.player.abilities.canFly && this.player.abilities.isFlying != packet202abilities.f()) { PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packet202abilities.f()); this.server.getPluginManager().callEvent(event); if (!event.isCancelled()) { this.player.abilities.isFlying = packet202abilities.f(); // Actually set the player's flying status } else { this.player.updateAbilities(); // Tell the player their ability was reverted } } // CraftBukkit end }
@EventHandler public void onFly(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); if ((player.getGameMode() != GameMode.CREATIVE)) { event.setCancelled(true); player.setAllowFlight(false); player.setFlying(false); player.setVelocity(player.getLocation().getDirection().multiply(1.6D).setY(1.0D)); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1.0F, -10.0F); } }
@EventHandler public void onFlightToggle(final PlayerToggleFlightEvent event) { if (!this.frozenPlayers.isEmpty() && !event.isCancelled() && this.frozenPlayers.containsKey(event.getPlayer().getUniqueId())) { if (!event.isFlying()) { event.setCancelled(true); final Location3w location = this.frozenPlayers.get(event.getPlayer().getUniqueId()); location.setYaw(event.getPlayer().getLocation().getYaw()); location.setPitch(event.getPlayer().getLocation().getPitch()); event.getPlayer().teleport(location); } } }
public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x()); // CraftBukkit start if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) { PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying()); this.server.getPluginManager().callEvent(event); if (!event.isCancelled()) { this.player.abilities.isFlying = packetplayinabilities.isFlying(); // Actually set the player's flying status } else { this.player.updateAbilities(); // Tell the player their ability was reverted } } // CraftBukkit end }
@EventHandler public void onJump(PlayerToggleFlightEvent e) { if(e.getPlayer().getGameMode() == GameMode.CREATIVE) { return; } XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName()); if(xp.hasDoubleJump()) { e.setCancelled(true); e.getPlayer().setAllowFlight(false); e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().add(new Vector(0, 3, 0)).normalize()); } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true) public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { if (!event.getPlayer().isFlying()) { if (context.getJailedPlayers().contains(event.getPlayer().getName())) { event.setCancelled(true); } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false) public void toggleFly(PlayerToggleFlightEvent e) { long now = System.currentTimeMillis(); if (this.blackWorlds.contains(e.getPlayer().getName())) return; PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(e.getPlayer().getPlayer(), false); Bukkit.getServer().getPluginManager().callEvent(event); /* if (!VaultManager.getInstance().perms.has(e.getPlayer(), "scb.mario.use") && (!VaultManager.getInstance().perms.has(e.getPlayer(), "scb.mario.triple"))) return; */ Player p = e.getPlayer(); Vector jump; Vector look; if (p.isSprinting()) { p.setNoDamageTicks(160); jump = p.getVelocity().multiply(1.2D).setY(2.0D); look = p.getLocation().getDirection().multiply(0.6D); p.playSound(p.getLocation(), Sound.EXPLODE, 1.0F, -5.0F); } else { p.setNoDamageTicks(140); jump = p.getVelocity().multiply(1.8D).setY(1.6D); look = p.getLocation().getDirection().multiply(0.7D); p.playSound(p.getLocation(), Sound.HORSE_ZOMBIE_HIT, 1.0F, 5.0F); } if ((e.isFlying()) && (p.getGameMode() != GameMode.CREATIVE)) { p.setFlying(false); p.setAllowFlight(false); jump.add(look); p.setVelocity(jump); } }
@EventHandler public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { if(!Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().isAlive(event.getPlayer())) { event.setCancelled(true); } }
@Override public void setup(TerminableConsumer consumer) { Events.subscribe(PlayerToggleFlightEvent.class) .handler(e -> getPlugin().refreshPlayer(e.getPlayer(), 1L)) .bindWith(consumer); }
@EventHandler public void onToggleFly(PlayerToggleFlightEvent e) { if (this.playerManager.isFrozen(e.getPlayer()) && e.getPlayer().isFlying()) { e.setCancelled(true); } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { if (!event.isFlying() && Freeze.this.frozenPlayers.containsKey(event.getPlayer())) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerToggleFlightEvent(PlayerToggleFlightEvent event) { User user = API.to(event.getPlayer()); if (user == null) return; if (this.call(new SkillEventFlight(user, event.isFlying())).isCancelled()) event.setCancelled(true); }
@Override public void eventTrigger(Event event) { if(event.getEventName().equalsIgnoreCase("playerjoinevent")){ eh.onPlayerJoin((PlayerJoinEvent)event); } else if(event.getEventName().equalsIgnoreCase("playerdropitemevent")){ eh.onPlayerDrop((PlayerDropItemEvent)event); } else if(event.getEventName().equalsIgnoreCase("playerinteractevent")){ eh.onPlayerInteract((PlayerInteractEvent)event); } else if(event.getEventName().equalsIgnoreCase("inventoryclickevent")){ eh.onInventoryClick((InventoryClickEvent)event); } else if(event.getEventName().equalsIgnoreCase("playertoggleflightevent")){ eh.onPlayerToggleFlight((PlayerToggleFlightEvent)event); } else if(event.getEventName().equalsIgnoreCase("playermoveevent")){ eh.onPlayerMove((PlayerMoveEvent)event); } else if(event.getEventName().equalsIgnoreCase("playerdropitemevent")){ eh.onPlayerDrop((PlayerDropItemEvent) event); } else if(event.getEventName().equalsIgnoreCase("playerinteractentityevent")){ eh.onPlayerInteractEntity((PlayerInteractEntityEvent) event); } else if(event.getEventName().equalsIgnoreCase("entitydamagebyentityevent")){ eh.onEntityDamageByEntity((EntityDamageByEntityEvent) event); } else if(event.getEventName().equalsIgnoreCase("playerquitevent")){ eh.onPlayerLeave((PlayerQuitEvent) event); } else if(event.getEventName().equalsIgnoreCase("foodlevelchangeevent")){ eh.onFoodLevelChange((FoodLevelChangeEvent) event); } else if(event.getEventName().equalsIgnoreCase("entitydamageevent")){ eh.onEntityDamage((EntityDamageEvent) event); } else if(event.getEventName().equalsIgnoreCase("weatherchangeevent")){ eh.onWeatherChange((WeatherChangeEvent) event); } else if(event.getEventName().equalsIgnoreCase("inventoryinteractevent")){ eh.onInventoryInteract((InventoryInteractEvent) event); } else if(event.getEventName().equalsIgnoreCase("worldloadevent")){ eh.onWorldLoad((WorldLoadEvent) event); } }
public void onPlayerToggleFlight(PlayerToggleFlightEvent event){ check("onPlayerToggleFlight", event); }
public ToggleFlyEvent(PlayerToggleFlightEvent e) { this.event = e; }
@EventHandler public void onFly(PlayerToggleFlightEvent e) { final Player p = e.getPlayer(); Arena arena = plugin.amanager.getPlayerArena(p.getName()); if (p.getGameMode() != GameMode.CREATIVE) { if(arena != null){ if(arena.getPlayersManager().isSpectator(p.getName())){ e.setCancelled(false); p.setFlying(true); return; } if(!arena.getStatusManager().isArenaRunning()){ e.setCancelled(true); return; } if(u.contains(p)){ e.setCancelled(true); return; } if(plugin.getConfig().get("doublejumps." + p.getName()) == null || plugin.getConfig().getInt("doublejumps." + p.getName()) == 0){ e.setCancelled(true); p.setAllowFlight(false); plugin.getConfig().set("doublejumps." + p.getName(), null); plugin.saveConfig(); return; }else{ plugin.getConfig().set("doublejumps." + p.getName(), plugin.getConfig().getInt("doublejumps." + p.getName()) - 1); } e.setCancelled(true); p.setFlying(false); p.setVelocity(p.getLocation().getDirection().multiply(1.5D).setY(0.7D)); TNTRun.getInstance().sound.NOTE_PLING(p, 5, 999); plugin.saveConfig(); u.add(p); Bukkit.getScheduler().runTaskLater(plugin, new Runnable(){ public void run(){ u.remove(p); p.setAllowFlight(true); } }, 20); }else{ if(p.hasPermission("tntrun.fly.everywhere")){ p.setFlying(true); p.setAllowFlight(true); }else{ p.setAllowFlight(false); p.setFlying(false); e.setCancelled(true); } } }else{ p.setAllowFlight(true); } }