Java Code Examples for org.bukkit.event.entity.EntityPickupItemEvent#getEntity()
The following examples show how to use
org.bukkit.event.entity.EntityPickupItemEvent#getEntity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemDropEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) @SuppressWarnings("unused") public void onPickupEvent(EntityPickupItemEvent event) { if (!(event.getEntity() instanceof Player)) { return; } Player player = (Player) event.getEntity(); if (event.isCancelled() || !plugin.getWorldManager().isSkyWorld(player.getWorld())) { clearDropInfo(event.getItem()); return; } if (wasDroppedBy(player, event) || player.hasPermission("usb.mod.bypassprotection") || plugin.playerIsOnIsland(player) || plugin.playerIsInSpawn(player)) { clearDropInfo(event.getItem()); return; // Allowed } // You are on another's island, and the stuff dropped weren't yours. event.setCancelled(true); plugin.notifyPlayer(player, tr("You cannot pick up other players' loot when you are a visitor!")); }
Example 2
Source File: PlayerEvents3.java From askyblock with GNU General Public License v2.0 | 6 votes |
@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); } }
Example 3
Source File: Player112Listener.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onPickup(EntityPickupItemEvent event) { if (!(event.getEntity() instanceof Player)) { return; } PlayerListener.onItemPickup((Player) event.getEntity(), event.getItem(), event); }
Example 4
Source File: Player112Listener.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onPickup(EntityPickupItemEvent event) { if (!(event.getEntity() instanceof Player)) { return; } PlayerListener.onItemPickup((Player) event.getEntity(), event.getItem(), event); }
Example 5
Source File: GuiListener.java From IF with The Unlicense | 5 votes |
/** * Handles users picking up items while their bottom inventory is in use. * * @param event the event fired when an entity picks up an item * @since 0.6.1 */ @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onEntityPickupItem(@NotNull EntityPickupItemEvent event) { if (!(event.getEntity() instanceof HumanEntity)) { return; } InventoryHolder holder = ((HumanEntity) event.getEntity()).getOpenInventory().getTopInventory().getHolder(); if (!(holder instanceof Gui)) { return; } Gui gui = (Gui) holder; if (gui.getState() != Gui.State.BOTTOM) { return; } int leftOver = gui.getHumanEntityCache().add((HumanEntity) event.getEntity(), event.getItem().getItemStack()); if (leftOver == 0) { event.getItem().remove(); } else { ItemStack itemStack = event.getItem().getItemStack(); itemStack.setAmount(leftOver); event.getItem().setItemStack(itemStack); } event.setCancelled(true); }
Example 6
Source File: Events_v1_12_R1_Up.java From Crazy-Crates with MIT License | 5 votes |
@EventHandler public void onItemPickUp(EntityPickupItemEvent e) { if (cc.isDisplayReward(e.getItem())) { e.setCancelled(true); } else { if (e.getEntity() instanceof Player) { Player player = (Player) e.getEntity(); if (cc.isInOpeningList(player)) { e.setCancelled(true); } } } }
Example 7
Source File: LootProtectListener.java From NyaaUtils with MIT License | 5 votes |
@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); } } }
Example 8
Source File: ListenerNewItemPickup.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority= EventPriority.HIGH, ignoreCancelled=true) public void onPickupItem(EntityPickupItemEvent e) { FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml"); if(!config.getBoolean("items.prevent-item-pickup")) return; LivingEntity entity = e.getEntity(); if(!(entity instanceof Player)) return; Player player = (Player) entity; ICombatManager combatManager = this.plugin.getCombatManager(); if(!combatManager.isInCombat(player)) return; e.setCancelled(true); sendMessage(player); }
Example 9
Source File: CustomItemListener.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
@EventHandler private void playerPickupItem(EntityPickupItemEvent event) { CustomItem customItem = CustomItemManager.getCustomItem(event.getItem().getItemStack()); Entity entity = event.getEntity(); if (entity instanceof Player && verifyCustomItem(customItem, (Player) entity, true)) { customItem.onPickup(event); } }
Example 10
Source File: KingsCrown.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
@Override public void onPickup(EntityPickupItemEvent event) { Player player = ((Player) event.getEntity()); PlayerInventory inv = player.getInventory(); ItemStack lastHelmet = inv.getHelmet(); if (lastHelmet == null || inv.addItem(lastHelmet).size() == 0) { inv.setHelmet(event.getItem().getItemStack()); event.getItem().remove(); event.setCancelled(true); if (shouldBroadcastMessage()) { UtilsMc.broadcastToWorld(player.getWorld(), MessageFormat.format("§6{0} §fhas been crown §6King§f!", player.getName(), getName())); } } }