@EventHandler(priority = EventPriority.HIGH) public void downElevator(PlayerToggleSneakEvent e) { Player p = e.getPlayer(); Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN); if (p.hasPermission("ironelevators.use") && !p.isSneaking() && b.getType() == elevatorMaterial) { b = b.getRelative(BlockFace.DOWN, minElevation); int i = maxElevation; //16 while (i > 0 && !( b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent() ) ) { //e.getPlayer().sendMessage("" + b.getLocation() + b.getType()); i--; b = b.getRelative(BlockFace.DOWN); } if (i > 0) { Location l = p.getLocation(); l.setY(l.getY() - maxElevation - 3 + i); p.teleport(l); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1); } } }
@EventHandler(priority = EventPriority.HIGH) public void downElevator(PlayerToggleSneakEvent e) { Player p = e.getPlayer(); Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN); if (!p.isSneaking() && b.getType() == elevatorMaterial) { b = b.getRelative(BlockFace.DOWN, minElevation); int i = maxElevation; //16 while (i > 0 && !(b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent())) { i--; b = b.getRelative(BlockFace.DOWN); } if (i > 0) { Location l = p.getLocation(); l.setY(l.getY() - maxElevation - 2 + i); p.teleport(l); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1); } } }
@Override public void handle( ConnectionHandler connectionHandler, MessageC15EntityAction message ) { FlexPlayer player = connectionHandler.getPlayer(); switch ( message.getActionId() ) { case 0: player.setSneaking( true ); EventFactory.call( new PlayerToggleSneakEvent( player, true ) ); break; case 1: player.setSneaking( false ); EventFactory.call( new PlayerToggleSneakEvent( player, false ) ); break; case 2: player.setSprinting( true ); EventFactory.call( new PlayerToggleSprintEvent( player, true ) ); break; case 3: player.setSprinting( false ); EventFactory.call( new PlayerToggleSprintEvent( player, false ) ); break; // todo handle other cases } }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true) public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event) { Player player = event.getPlayer(); Block block = player.getLocation().getBlock(); /* Check if player starts sneaking on top of obsidian */ if ( event.isSneaking() && PortalCheck.is_valid_portal(block) ) { Portals.instance.getLogger().info(player.getName() + " tried to use a portal by sneaking at" + " " + block.getWorld().getName() + " " + block.getX() + " " + block.getY() + " " + block.getZ() + "."); PortalUtils.teleport(player); } }
@EventHandler public void onPlayerSneak(PlayerToggleSneakEvent event) { if (event.isSneaking()) { Block b = event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN); Elevator e1 = LocationManager.getManager().get(b.getLocation(), Elevator.class); if (e1 != null) { Elevator e2 = e1.findOtherElevator(BlockFace.DOWN); if (e2 != null) { Block b1 = e2.getLocation().getBlock().getRelative(BlockFace.UP); if (!b1.getType().isSolid() && !b1.getRelative(BlockFace.UP).getType().isSolid()) { Location dest = b1.getLocation().add(0.5, 0, 0.5); dest.setPitch(event.getPlayer().getLocation().getPitch()); dest.setYaw(event.getPlayer().getLocation().getYaw()); event.getPlayer().teleport(dest); event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.PISTON_RETRACT, 1.0f, 1.8f); } } } } }
@EventHandler public void onSneakEvent(PlayerToggleSneakEvent event) { Player p = event.getPlayer(); if (!casters.containsKey(p.getUniqueId())) casters.put(p.getUniqueId(), new Caster()); final Caster c = casters.get(p.getUniqueId()); PlayerDataRPG pd = plugin.getPD(p); if (pd != null) pd.updateHealthManaDisplay(); c.clear(); }
/** * Keeps track of player sneaking; if they are sneaking, we track when the * snuck, or, clear if unsnuck. * * @param event * the sneak toggle event */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void toggleSneakEvent(PlayerToggleSneakEvent event) { if (event.isSneaking()) { sneakingSince.computeIfAbsent(event.getPlayer().getUniqueId(), u -> { if (event.getPlayer().hasPermission("addgun.data")) { event.getPlayer().sendMessage(ChatColor.GOLD + " sneak started"); } return System.currentTimeMillis(); }); } else { if (sneakingSince.containsKey(event.getPlayer().getUniqueId()) && event.getPlayer().hasPermission("addgun.data")) { event.getPlayer().sendMessage(ChatColor.GOLD + " sneak cleared"); } sneakingSince.remove(event.getPlayer().getUniqueId()); } }
@EventHandler public void onPlayerToggleSneak(PlayerToggleSneakEvent event) { Camera camera = this.getPlayerCamera(event.getPlayer()); if (camera != null && camera.isFixed()) event.setCancelled(true); }
@EventHandler public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent e) { // Sneaking = !sneaking because of badly timed events for (Entity en : e.getPlayer().getWorld().getEntities()) { if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().distance(e.getPlayer().getLocation()) <= 1.5 && en.getLocation().getY() < e.getPlayer().getLocation().getY()) { if (!e.getPlayer().isSneaking()) { //e.getPlayer().sendMessage("down"); if (getElevatorDown(en, e.getPlayer()) != null) {e.getPlayer().teleport(getElevatorDown(en, e.getPlayer()).getLocation().add(0, 1, 0));} } } } }
@EventHandler public void sneak(PlayerToggleSneakEvent e){ if(rs.getPlayerData(e.getPlayer())==null)return; if(rs.getPlayerData(e.getPlayer()).getPhysical_strength()<rs.getSneaking()){ e.setCancelled(true); e.getPlayer().setSneaking(false); } }
@Override protected Listener listener(Consumer<Player> callback) { return new Listener() { @EventHandler public void onSneak(PlayerToggleSneakEvent event) { if (!event.isSneaking() && player.equals(event.getPlayer())) { callback.accept(event.getPlayer()); } } }; }
@EventHandler public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event){ Player p = event.getPlayer(); if(!p.isSneaking() && Config.enableSneak){ p.setGliding(true); } }
@EventHandler public void on(PlayerToggleSneakEvent event) { PlayerData playerData = plugin.playerManager.getData(event.getPlayer().getUniqueId()); if (playerData != null) { if (playerData.isInGame() && playerData.isSpectator) { //Reset the gamemode when the player "leaves" their target event.getPlayer().setGameMode(GameMode.ADVENTURE); event.getPlayer().setAllowFlight(true); event.getPlayer().setFlying(true); } } }
@EventHandler public void onSneak(PlayerToggleSneakEvent e) { Player p = e.getPlayer(); if (p.getGameMode() == GameMode.SPECTATOR) { return; } if (p.getGameMode() == GameMode.CREATIVE) { return; } if (!p.hasPermission("tdj.use")) { return; } if (!p.hasPermission("tdj.groundpound")) { return; } if (!Grounded.contains(p.getUniqueId().toString())) { return; } if (p.isOnGround()) { return; } if (FlightCommand.FlyingPlayers.contains(p.getUniqueId().toString())) { return; } if (DoubleJumpCommand.DisablePlayers.contains(p.getUniqueId().toString())) { return; } if (!ConfigManager.getConfig().getBoolean("GroundPound.Enabled")){ return; } if (GroundPoundCommand.groundPoundDisabled.contains(p.getUniqueId().toString())) { return; } p.setVelocity(new Vector(0, -5, 0)); }
@EventHandler public void playerToggleSneakEvent(PlayerToggleSneakEvent event) { Player player = event.getPlayer(); PlayerData playerData = PlayerData.getPlayerData(player); playerData.setPlayerSneaking(event.isSneaking()); }
@EventHandler(priority = EventPriority.HIGHEST,ignoreCancelled = true) public void Teleport(PlayerToggleSneakEvent event) { if(event.isSneaking()) { Player player = event.getPlayer(); Block b = player.getLocation().getBlock().getRelative(BlockFace.DOWN); if(b.getType() == Material.QUARTZ_ORE) { UUID owner = getBlocksOwner(b); if(owner != null) { AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(p != null) { Teleporter tele = teleporters.get(owner); if(tele.isLinked() && tele.getOwner().getTeam() == p.getTeam() && tele.canUse()) { Location loc; //if(new Loc(b.getLocation()).isEqual(tele.getLoc1())) if(tele.getLoc1().equals(b.getLocation())) loc = tele.getLoc2().toLocation(); else loc = tele.getLoc1().toLocation(); loc.setY(loc.getY()+1); player.teleport(this.getMiddle(loc)); loc.getWorld().playEffect(loc, Effect.MOBSPAWNER_FLAMES, 1); tele.getLoc1().toLocation().getWorld().playSound(tele.getLoc1().toLocation(), Sound.ENDERMAN_TELEPORT, 1F,(float)Math.random()); tele.getLoc2().toLocation().getWorld().playSound(tele.getLoc2().toLocation(), Sound.ENDERMAN_TELEPORT, 1F,(float)Math.random()); tele.delay(); event.setCancelled(true); } } } } } }
/** * Handle player crouch. */ @EventHandler(ignoreCancelled = true) public void onPlayerToggleSneak(PlayerToggleSneakEvent event) { Player player = event.getPlayer(); if (isFlightCapable(player) && event.isSneaking()) { getState(player).onCrouch(); } }
@EventHandler public void shift(PlayerToggleSneakEvent e) { if (e.isSneaking()) { sneakCache.add(e.getPlayer()); } else { launchPlayer(e.getPlayer()); sneakCache.remove(e.getPlayer()); e.getPlayer().setLevel(0); e.getPlayer().setExp(0); } }
public void onPlayerSneaks(PlayerToggleSneakEvent e) { Player player = e.getPlayer(); if (player.getLocation().getBlock().equals(new Location(Bukkit.getWorld("Survival"), 179, 80, 227).getBlock()) || player.getLocation().getBlock().equals(new Location(Bukkit.getWorld("Survival"), 173, 64, 227).getBlock())) { if (timeout.containsKey(player)) { if (timeout.get(player) + 5 > System.currentTimeMillis()/1000) return; } if (e.isSneaking()) { attemptTeleport(player); } else { cancelTeleport(player); } } }
public void onPlayerSneaks(PlayerToggleSneakEvent e) { Player player = e.getPlayer(); if (player.getLocation().getBlock().equals(pressurePlate.getBlock())) { if (timeout.containsKey(player)) { if (timeout.get(player) + 5 > System.currentTimeMillis()/1000) return; } if (e.isSneaking()) { attemptTeleport(player); } else { cancelTeleport(player); } } }
@EventHandler public void onShift(PlayerToggleSneakEvent event) { Player player = event.getPlayer(); Connection connection = ProtocolSupportAPI.getConnection(player); if ( player.isInsideVehicle() && (connection != null) && (connection.getVersion().getProtocolType() == ProtocolType.PC) && connection.getVersion().isBeforeOrEq(ProtocolVersion.MINECRAFT_1_5_2) ) { player.leaveVehicle(); } }
@EventHandler(ignoreCancelled = true) public void onSneak(PlayerToggleSneakEvent e) { Player p = e.getPlayer(); if (!workerz.containsKey(p.getUniqueId())) { // use a little CPU to prevent network abuse // if player has rgb armor, but no perms, and spam sneaks // they would trigger a TON of message sends (lines 131, 133) if(sneaks.containsKey(p.getUniqueId())) { long last = sneaks.get(p.getUniqueId()); if(System.currentTimeMillis() - last < 5000) { return; } sneaks.remove(p.getUniqueId()); } for (ItemStack is : p.getInventory().getArmorContents()) { ItemMeta meta; if (is != null && (meta = is.getItemMeta()) instanceof LeatherArmorMeta) { if (meta.hasLore()) { Worker worker = getWorker(p, meta.getLore()); if (worker != null) { this.initWorker(p, worker); return; } } } } } }
@EventHandler public void onSneak(PlayerToggleSneakEvent e) { if (!e.isSneaking()) { if (activePlayers.containsKey(e.getPlayer().getName())) { activePlayers.put(e.getPlayer().getName(), activePlayers.get(e.getPlayer().getName()) + 1); } } }
@EventHandler(priority=EventPriority.NORMAL, ignoreCancelled=false) public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event) { Player player = event.getPlayer(); if(player.getVehicle()!=null){ Events.sendMountPacket(player); } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) private void onPlayerToggleSneak(PlayerToggleSneakEvent event) { Player player = event.getPlayer(); if (Ghosts.p.getGhostManager().isGhost(player)) { PlayerManager.spook(player); } }
@EventHandler public void onPlayerToggleSneak(PlayerToggleSneakEvent event) { if (event.getPlayer().hasPermission("supersneak.use")) { if (event.isSneaking()){ event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 9)); } else { event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 0, 0), true); } } }
@EventHandler(ignoreCancelled = true) // Prevent dismounting from the camera mount. public void onSneak(PlayerToggleSneakEvent evt) { evt.setCancelled(isWatching(evt.getPlayer()) && evt.isSneaking()); }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event) { User user = API.to(event.getPlayer()); if (user == null) return; if (this.call(new SkillEventSneak(user, event.isSneaking())).isCancelled()) event.setCancelled(true); }
@EventHandler(priority = LOWEST) public void pre(PlayerToggleSneakEvent event) { handle(event); }
@EventHandler(ignoreCancelled = true, priority = HIGHEST) public void handle(PlayerToggleSneakEvent event) { if (isLocked(event.getPlayer().getUniqueId())) { event.setCancelled(true); } }
@EventHandler public void PlayerToggleSneak(PlayerToggleSneakEvent event) { if (donorShop != null) donorShop.onPlayerSneaks(event); // drunkenWizard.onPlayerSneaks(event); }