@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVisitorPickup(final EntityPickupItemEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } if (e.getEntity() instanceof Player) { Player player = (Player)e.getEntity(); if (!Util.inWorld(player)) { return; } Island island = plugin.getIslands().getIslandAt(e.getItem().getLocation()); if ((island != null && island.getFlag(SettingsFlag.ITEM_PICKUP)) || player.isOp() || VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getIslands().locationIsOnIsland(player, e.getItem().getLocation())) { return; } e.setCancelled(true); } }
@EventHandler public void pickupItemEvent(EntityPickupItemEvent event){ if(event.getItem().getItemStack().getType().equals(Material.EMERALD)){ if(event.getItem().getItemStack().getItemMeta().hasDisplayName()){ if(event.getItem().getItemStack().getItemMeta().getDisplayName().contains("$")){ if(event.getEntity() instanceof Player){ String name = event.getItem().getItemStack().getItemMeta().getDisplayName(); name = name.replace("$", ""); new Treasury(new Account((Player)event.getEntity()).getLoadedCharacter()).deposit(Integer.valueOf(name)); ((Player)event.getEntity()).sendMessage(ChatColor.YELLOW+"You have picked up $"+ Integer.valueOf(name)+" Dollars!"); } event.setCancelled(true); event.getItem().remove(); } } } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVisitorPickup(final EntityPickupItemEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } if (e.getEntity() instanceof Player) { Player player = (Player)e.getEntity(); if (!IslandGuard.inWorld(player)) { return; } Island island = plugin.getGrid().getIslandAt(e.getItem().getLocation()); if ((island != null && island.getIgsFlag(SettingsFlag.VISITOR_ITEM_PICKUP)) || player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().locationIsOnIsland(player, e.getItem().getLocation())) { return; } e.setCancelled(true); } }
@EventHandler public void onItemPickup(EntityPickupItemEvent event) { LivingEntity ent = event.getEntity(); if (ent instanceof Player) { Player player = (Player) ent; PlotPlayer pp = BukkitUtil.getPlayer(player); Plot plot = BukkitUtil.getLocation(player).getOwnedPlot(); if (plot == null) { return; } UUID uuid = pp.getUUID(); if (!plot.isAdded(uuid) && Flags.DROP_PROTECTION.isTrue(plot)) { event.setCancelled(true); } } }
/** * THIS METHOD IS FOR TESTING ONLY AND WILL NOT BE USED IN THE FINAL PRODUCTION */ @EventHandler public void onEntityPickup (EntityPickupItemEvent event) { Entity player = event.getEntity (); if (player instanceof Player) { player.sendMessage (event.getItem ().getName ()); // TODO: Use the below way to retrieve the Material Type from an Item. player.sendMessage (event.getItem ().getItemStack ().getType ().toString ()); player.sendMessage (event.getItem ().getItemStack ().getData ().toString ()); player.sendMessage (event.getItem ().getItemStack ().getItemMeta ().toString ()); } }
@EventHandler public void onPickup(EntityPickupItemEvent event) { if (event.getEntity() instanceof Player) { if (event.getItem() != null && event.getItem().getItemStack().getType() == Material.WOOL) { if (event.getItem().getItemStack().getData().getData() == color) { handleWoolPickup(((Player) event.getEntity()).getPlayer()); } } } }
@EventHandler public void onPickup(EntityPickupItemEvent e) { if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true); else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) { e.setCancelled(true); e.getItem().remove(); } }
/** * This prevents from picking up a gun if you already have one * * @param event The pickup event. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void pickupWeaponEvent(EntityPickupItemEvent event) { if (event.getItem() == null) return; StandardGun gun = findGun(event.getItem().getItemStack()); if (gun != null && gun.isLimitToOne() && gun.hasGun(event.getEntity())) { event.setCancelled(true); gun.optionallyWarn(event.getEntity(), ChatColor.RED + "A " + ChatColor.AQUA + gun.getName() + ChatColor.RED + " is already in inventory, you cannot pick up another."); } }
/** * This prevents from picking up a gun if you already have one * * @param event The pickup event. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void pickupWeaponEvent(EntityPickupItemEvent event) { if (!enabled || event.getItem() == null) return; if (isGun(event.getItem().getItemStack()) && hasGun(event.getEntity())) { event.setCancelled(true); if (!warned.contains(event.getEntity().getUniqueId())) { event.getEntity().sendMessage(ChatColor.RED + "A " + ChatColor.AQUA + getName() + ChatColor.RED + " is already in inventory, it's too heavy to carry two!"); warned.add(event.getEntity().getUniqueId()); } } }
@EventHandler public void onItemPickup(EntityPickupItemEvent event){ for(Anvil anvil : anvils){ if(anvil.getItem().equals(event.getItem())){ event.setCancelled(true); } } }
@EventHandler(priority = EventPriority.MONITOR) public void onPickupItem(EntityPickupItemEvent e) { if (e.getItem() != null && MarketManager.isMarketItem(e.getItem().getItemStack())) { e.getItem().setItemStack(new ItemStack(Material.AIR)); e.setCancelled(true); } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPickup(EntityPickupItemEvent e) { if (plugin.cfg.lootProtectMode == LootProtectMode.OFF || !(e.getEntity() instanceof Player)) return; Player p = (Player) e.getEntity(); if (!p.isSneaking() && bypassVanillaPlayer.get(p.getUniqueId()) == VanillaStrategy.REJECT) { ItemStack item = e.getItem().getItemStack(); if (!(item.hasItemMeta() && item.getItemMeta().hasLore())) { e.setCancelled(true); } } }
@EventHandler public void onPickup(final EntityPickupItemEvent event) { if (event.getEntity() instanceof Player) { final PlayerEquips equips = Enchantments.getEquipmentData((Player) event.getEntity()); Tasks.schedule(() -> equips.updateWeapon(((Player) event.getEntity()).getInventory())); } }
@EventHandler public void onPickup(EntityPickupItemEvent event) { if (event instanceof Player && isSpectating((Player) event.getEntity())) { event.setCancelled(true); } }
@EventHandler(ignoreCancelled = true) // Prevent items that entities pickup from being lost on death. public void onItemPickup(EntityPickupItemEvent evt) { addPlayerDamage(evt.getEntity(), 100); }
@EventHandler(priority = EventPriority.MONITOR) public void onPickup(EntityPickupItemEvent e) { if (plugin.cfg.dropProtectMode == DropProtectMode.OFF) return; items.invalidate(e.getItem().getEntityId()); }