/** * Called when a player attempts to pickup an item * * @param event Relevant event details */ @Override public void onPlayerPickupItem(PlayerPickupItemEvent event) { if (event.isCancelled()) { return; } GlobalConfiguration cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName()); if (wcfg.getBlacklist() != null) { Item ci = event.getItem(); if (!wcfg.getBlacklist() .check( new ItemAcquireBlacklistEvent( BukkitPlayer.wrapPlayer(plugin, event.getPlayer()), toVector(ci.getLocation()), ci.getItemStack().getTypeId()), false, false)) { event.setCancelled(true); return; } } }
@EventHandler public void PlayerPickupItemEvent(PlayerPickupItemEvent event) { if (event.getItem().hasMetadata("ce.Volley")) { event.getItem().remove(); event.setCancelled(true); } }
@EventHandler public void onPlayerPickupItem(PlayerPickupItemEvent e) { Player p = e.getPlayer(); if (plugin.hidden.contains(p.getName())) { e.setCancelled(true); } }
@EventHandler public void onPlayerPickupItem(PlayerPickupItemEvent event) { Player player = event.getPlayer(); ArenaPlayer ap = ArenaPlayer.parsePlayer(player.getName()); if (!arena.equals(ap.getArena())) { return; } if (usesPowerups != null) { debug.i("onPlayerPickupItem: fighting player", player); debug.i("item: " + event.getItem().getItemStack().getType(), player); Iterator<Powerup> pi = usesPowerups.puTotal.iterator(); while (pi.hasNext()) { Powerup p = pi.next(); debug.i("is it " + p.item + "?", player); if (event.getItem().getItemStack().getType().equals(p.item)) { debug.i("yes!", player); Powerup newP = new Powerup(p); if (usesPowerups.puActive.containsKey(player)) { usesPowerups.puActive.remove(player); } usesPowerups.puActive.put(player, newP); arena.broadcast(Language.parse(MSG.MODULE_POWERUPS_PLAYER, player.getName(), newP.name)); event.setCancelled(true); event.getItem().remove(); if (newP.canBeTriggered()) newP.activate(player); // activate for the first time return; } } } }
@Override public void onPlayerPickupItem(PlayerPickupItemEvent event) { Player player = event.getPlayer(); if (plugin.isPlayerNP(player.getName())) { event.setCancelled(true); } }
@EventHandler public void onPlayerPickup(PlayerPickupItemEvent e) { ItemStack item = e.getItem().getItemStack(); String locale = Locale.getPlayerLocale(e.getPlayer()); if (ItemManager.toRPGItem(item) != null) { RPGItem.updateItem(item, locale); e.getItem().setItemStack(item); } }
@EventHandler(priority = EventPriority.HIGH) public void itemPickup(PlayerPickupItemEvent event) { if (teamUtil.getPlayerTeam(event.getPlayer()).equals("red") || teamUtil.getPlayerTeam(event.getPlayer()).equals("blue") || event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) { event.setCancelled(false); } else { event.setCancelled(true); } }
@EventHandler public void onItemPickup(PlayerPickupItemEvent e) { SpleefPlayer player = HeavySpleef.getInstance().getSpleefPlayer(e.getPlayer()); if (!player.isActive()) { return; } e.setCancelled(true); }
public void onPlayerPickupItem(PlayerPickupItemEvent event) { SpoutPlayer sPlayer = SpoutManager.getPlayer(event.getPlayer()); Item item = event.getItem(); String music = plugin.config.getString("effect." + item.getItemStack().getType().name(), ""); if (music == "") { music = plugin.config.getString("effect.DEFAULT", ""); } if (music != "") { SpoutManager.getSoundManager().playCustomSoundEffect(plugin, sPlayer, music, true); } }
/** * Monitor PlaterPickupItem events. * * @param event The event to watch */ @EventHandler(ignoreCancelled = true) public void onPlayerPickupItem(PlayerPickupItemEvent event) { PlayerProfile profile = Users.getProfile(event.getPlayer()); if (profile == null) { return; } if (profile.getAbilityMode(AbilityType.BERSERK)) { event.setCancelled(true); } }
@EventHandler(ignoreCancelled = true) public void onPickupItem(PlayerPickupItemEvent event) { Item item = event.getItem(); ProjectileInfo info = itemProjectiles.get(item); if (info != null) { event.setCancelled(true); projectileHitEntity(item, event.getPlayer(), info); item.remove(); itemProjectiles.remove(item); info.monitor.stop(); } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) public void onPlayerPickupItem(PlayerPickupItemEvent event) { Player p = event.getPlayer(); ItemStack i = event.getItem().getItemStack(); if (p == null) return; if (i == null) return; if (!p.hasPermission("orbia.keepitems") && !p.getGameMode().equals(GameMode.CREATIVE)) return; if (!itemHandler.isCustomItem(i) && remove.contains(i.getType())) { event.getItem().remove(); event.setCancelled(true); } }
/** Pickup * */ @EventHandler public void onPickup(PlayerPickupItemEvent e) { /** Lobby * */ if (Main.getState() == GameState.LOBBY) e.setCancelled(true); /** Spectator * */ if (Game.spectators.contains(e.getPlayer().getName())) e.setCancelled(true); /** Remove dropped item in arrayList * */ if (IngameState.dropped_items.containsValue(e.getItem())) { IngameState.dropped_items.remove(e.getItem()); } }
@EventHandler public void SpectatorItems(PlayerPickupItemEvent event) { Player p = event.getPlayer(); String pname = p.getName(); for (i = 0; i < plugin.Watching.size(); i++) { if (plugin.Watching.get(i) != null) { if (plugin.Watching.get(i).contains(pname)) { event.setCancelled(true); p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!"); } } } }
@EventHandler public void onPlayerPickup(PlayerPickupItemEvent event) { // Check whether the player has accepted the rules and is allowed to pick up drops. If not, // cancel the event. if (VAR.config.getBoolean("enableRules")) { if (!VAR.pLog .getString("players." + event.getPlayer().getName() + ".Has accepted rules") .equalsIgnoreCase("true")) { if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("pickupdrops")) { event.setCancelled(true); } } } }
/** * Handles item picking up.<br> * If the player is in an arena, the game's onItemPickup method is called.<br> * If the player is spectating an arena, the event is cancelled. */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemPickup(PlayerPickupItemEvent event) { String playerName = event.getPlayer().getName(); if (ultimateGames.getPlayerManager().isPlayerInArena(playerName)) { Arena arena = ultimateGames.getPlayerManager().getPlayerArena(playerName); if (arena.getStatus() == ArenaStatus.RUNNING) { arena.getGame().getGamePlugin().onItemPickup(arena, event); } else { event.setCancelled(true); } } else if (ultimateGames.getPlayerManager().isPlayerSpectatingArena(playerName)) { event.setCancelled(true); } }
/** * This method sets plugin.carriers, compass direction, and gives a hat. <br> * <br> * * <pre> * 1. Give the bomb carrier a hat so that other players know WHO has the bomb. * 2. Set the compass direction for all players to point to the objective: * - This helps attackers find the opponents base. * - This helps defenders find their own base. * </pre> * * @param e PlayerPickupItemEvent: checks to see if they picked up the bomb item, or a different * item. */ @ArenaEventHandler public void onBombPickup(PlayerPickupItemEvent e) { plugin.debug.log("onBombPickup() called"); if (e.getItem().getItemStack().getType() != plugin.getBombBlock()) return; if (carrier == null) { carrier = e.getPlayer().getName(); e.getPlayer().getInventory().setHelmet(new ItemStack(plugin.getBombBlock())); ArenaTeam team2 = getOtherTeam(e.getPlayer()); int teamID = team2.getId(); Location base_loc = teamBases.get(teamID); setCompass(base_loc); createBaseHologram(base_loc); msgAll(team2.getPlayers(), "Hurry back to defend your base from being destroyed!"); msgAll( getMatch().getArena().getTeam(e.getPlayer()).getPlayers(), "Your team has the bomb! Follow your compass to find the other teams base."); } else { e.setCancelled(true); e.getPlayer() .sendMessage( "There can only be ONE bomb per Match. " + carrier + " currently has the bomb."); e.getItem().remove(); } } // END OF PlayerPickupItemEvent
@EventHandler public void onTakeUpMelon(PlayerPickupItemEvent event) { if (melons.contains(event.getItem()) && event.getItem().getTicksLived() > 5) { event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5 * 20, 2)); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 1, 1f); event.setCancelled(true); melons.remove(event.getItem()); event.getItem().remove(); } if (melonBlocks.contains(event.getItem())) event.setCancelled(true); }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerPickupItem(final PlayerPickupItemEvent event) { final ISettings settings = ess.getSettings(); if (!settings.getData().getCommands().getAfk().isDisableItemPickupWhileAfk()) { return; } final IUser user = userMap.getUser(event.getPlayer()); if (user.getData().isAfk()) { event.setCancelled(true); } }
@EventHandler public void onPickup(PlayerPickupItemEvent ppie) { Player player = ppie.getPlayer(); Game game = Main.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() != GameState.WAITING) { if (game.isSpectator(player)) { ppie.setCancelled(true); } return; } ppie.setCancelled(true); }
private boolean wasDroppedBy(Player player, PlayerPickupItemEvent event) { ItemStack itemStack = event.getItem().getItemStack(); ItemMeta meta = itemStack.getItemMeta(); List<String> lore = meta.getLore(); if (lore != null && !lore.isEmpty()) { String lastLine = lore.get(lore.size() - 1); return lastLine.equalsIgnoreCase("Dropped by: " + player.getName()); } return false; }
@Override public void onPlayerPickupItem(PlayerPickupItemEvent event) { if (event.isCancelled() || plugin .getConfigManager() .getProperties() .disabledWorlds .contains(event.getPlayer().getWorld().getName())) return; final Hero hero = plugin.getHeroManager().getHero(event.getPlayer()); if (hero.hasEffectType(EffectType.DISARM) && Util.isWeapon(event.getItem().getItemStack().getType())) { event.setCancelled(true); return; } plugin .getServer() .getScheduler() .scheduleSyncDelayedTask( plugin, new Runnable() { @Override public void run() { hero.checkInventory(); } }); if (!hero.hasParty()) return; HeroParty party = hero.getParty(); if (!party.updateMapDisplay() && event.getItem().getItemStack().getType().toString().equalsIgnoreCase("MAP")) { party.setUpdateMapDisplay(true); } }
public void a_(EntityHuman entityhuman) { if (!this.world.isStatic) { // CraftBukkit start ItemStack itemstack = new ItemStack(Item.ARROW, 1); if (this.inGround && this.fromPlayer && this.shake <= 0 && entityhuman.inventory.canHold(itemstack) > 0) { net.minecraft.server.EntityItem item = new net.minecraft.server.EntityItem( this.world, this.locX, this.locY, this.locZ, itemstack); PlayerPickupItemEvent event = new PlayerPickupItemEvent( (org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), item), 0); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } } // CraftBukkit end if (this.inGround && this.fromPlayer && this.shake <= 0 && entityhuman.inventory.pickup(new ItemStack(Item.ARROW, 1))) { this.world.makeSound( this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityhuman.receive(this, 1); this.die(); } } }
@EventHandler(priority = EventPriority.MONITOR) public void onPickupEvent(PlayerPickupItemEvent event) { Player player = event.getPlayer(); if (!plugin.isSkyWorld(player.getWorld())) { return; } if (wasDroppedBy(player, event)) { clearDropInfo(event.getItem().getItemStack()); return; // Allowed } if (player.hasPermission("usb.mod.bypassprotection")) { clearDropInfo(event.getItem().getItemStack()); return; } if (plugin.playerIsOnIsland(player) || plugin.playerIsInSpawn(player)) { clearDropInfo(event.getItem().getItemStack()); return; } // You are on another's island, and the stuff dropped weren't yours. event.setCancelled(true); plugin.notifyPlayer(player, "You cannot pick up other players' loot when you are a visitor!"); }
@EventHandler(priority = EventPriority.LOW) public void onPlayerPickupItem(PlayerPickupItemEvent event) { if (event == null) return; if (event.getPlayer() == null) event.setCancelled(true); if (validateAuthorizer(event.getPlayer())) event.setCancelled(true); else if (validateClickAuth(event.getPlayer(), null)) event.setCancelled(true); }
public void c_(EntityHuman entityhuman) { if (!this.world.isStatic && this.inGround && this.shake <= 0) { // CraftBukkit start ItemStack itemstack = new ItemStack(Item.ARROW); if (this.fromPlayer == 1 && entityhuman.inventory.canHold(itemstack) > 0) { EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); PlayerPickupItemEvent event = new PlayerPickupItemEvent( (org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), 0); event.setCancelled(!entityhuman.canPickUpLoot); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } } // CraftBukkit end boolean flag = this.fromPlayer == 1 || this.fromPlayer == 2 && entityhuman.abilities.canInstantlyBuild; if (this.fromPlayer == 1 && !entityhuman.inventory.pickup(new ItemStack(Item.ARROW, 1))) { flag = false; } if (flag) { this.makeSound( "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityhuman.receive(this, 1); this.die(); } } }
/** * Handles all item pickup events by players. If the item that was picked up is the gem used for * money, credit the player $1 and remove the gem. * * @param event The item pickup event */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false) public void onItemPickup(PlayerPickupItemEvent event) { Player player = event.getPlayer(); String giveMoneyCommand = "money give " + player.getName() + " 1"; if (event.getItem().getItemStack().getItemMeta().equals(moneyGem.getItemMeta())) { for (int i = 0; i < event.getItem().getItemStack().getAmount(); i++) { plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), giveMoneyCommand); } if (event.getItem().getItemStack().getAmount() == 1) { player.sendMessage(ChatColor.DARK_GREEN + "You have found a rare gem!"); } else if (event.getItem().getItemStack().getAmount() > 1) { player.sendMessage( ChatColor.DARK_GREEN + "You have found " + event.getItem().getItemStack().getAmount() + " rare gems!"); } event.getItem().remove(); event.setCancelled(true); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerPickupItemEvent(PlayerPickupItemEvent event) { if (event.isCancelled()) return; final Player player = event.getPlayer(); final Item item = event.getItem(); if (player.getWorld() != plugin.getIslandWorld()) return; if (player.isOp()) return; if (player.hasPermission("islandworld.bypass.island")) return; if (item != null && !(plugin.getConfig().getBoolean("flags.item-pickup", false) || plugin.canBuildOnLocation(player, item.getLocation()))) event.setCancelled(true); plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled()); }
@EventHandler public void onPlayerPickupItem(PlayerPickupItemEvent e) { if (!plugin.getConfig().getBoolean("Complete")) return; e.setCancelled(true); }
@EventHandler public void onItemPickup(PlayerPickupItemEvent event) { if (um.isSpectator(event.getPlayer().getName())) event.setCancelled(true); }