org.bukkit.event.player.PlayerDropItemEvent Java Examples
The following examples show how to use
org.bukkit.event.player.PlayerDropItemEvent.
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: WarpPowderListener.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
@EventHandler public void onDrop(PlayerDropItemEvent event) { Player player = event.getPlayer(); if (event.isCancelled() || !Main.isPlayerInGame(player)) { return; } GamePlayer gPlayer = Main.getPlayerGameProfile(player); Game game = gPlayer.getGame(); if (gPlayer.isSpectator) { return; } WarpPowder warpPowder = (WarpPowder) game.getFirstActivedSpecialItemOfPlayer(player, WarpPowder.class); if (warpPowder != null) { if (warpPowder.getStack().equals(event.getItemDrop().getItemStack())) { event.setCancelled(true); } } }
Example #2
Source File: WarpPowderListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onDrop(PlayerDropItemEvent event) { Player p = event.getPlayer(); Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p); if (g == null) { return; } if (g.getState() == GameState.RUNNING && event.getItemDrop().getItemStack().getItemMeta().getDisplayName() != null && event.getItemDrop().getItemStack().getItemMeta().getDisplayName() .equals(BedwarsRel._l("ingame.specials.warp-powder.cancel"))) { event.setCancelled(true); } }
Example #3
Source File: PlayerListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onDrop(PlayerDropItemEvent die) { Player p = die.getPlayer(); Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p); if (g == null) { return; } if (g.getState() != GameState.WAITING) { if (g.isSpectator(p)) { die.setCancelled(true); } return; } die.setCancelled(true); }
Example #4
Source File: WarpPowderListener.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
@EventHandler public void onDrop(PlayerDropItemEvent event) { Player player = event.getPlayer(); if (event.isCancelled() || !Main.isPlayerInGame(player)) { return; } GamePlayer gPlayer = Main.getPlayerGameProfile(player); Game game = gPlayer.getGame(); if (gPlayer.isSpectator) { return; } WarpPowder warpPowder = (WarpPowder) game.getFirstActivedSpecialItemOfPlayer(player, WarpPowder.class); if (warpPowder != null) { if (warpPowder.getStack().equals(event.getItemDrop().getItemStack())) { event.setCancelled(true); } } }
Example #5
Source File: Soulbound.java From MineTinker with GNU General Public License v3.0 | 6 votes |
/** * Effect if a player drops an item * * @param event the event */ @EventHandler(ignoreCancelled = true) public void effect(PlayerDropItemEvent event) { Item item = event.getItemDrop(); ItemStack tool = item.getItemStack(); if (!(modManager.isArmorViable(tool) || modManager.isToolViable(tool) || modManager.isWandViable(tool))) { return; } if (!modManager.hasMod(tool, this)) { return; } if (toolDroppable) { return; } ChatWriter.logModifier(event.getPlayer(), event, this, tool, "Tool not droppable"); event.setCancelled(true); }
Example #6
Source File: BlockListeners.java From CratesPlus with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onItemDrop(PlayerDropItemEvent event) { if (!cratesPlus.getConfigHandler().isDisableKeySwapping()) return; String title; ItemStack item = event.getItemDrop().getItemStack(); for (Map.Entry<String, Crate> crate : cratesPlus.getConfigHandler().getCrates().entrySet()) { if (!(crate.getValue() instanceof KeyCrate)) { continue; } KeyCrate keyCrate = (KeyCrate) crate.getValue(); Key key = keyCrate.getKey(); if (key == null) continue; title = key.getName(); if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains(title)) { MessageHandler.sendMessage(event.getPlayer(), "&cYou can not drop crate keys", crate.getValue(), null); event.setCancelled(true); return; } } }
Example #7
Source File: ItemsDroppedListener.java From Statz with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerDrop(final PlayerDropItemEvent event) { final PlayerStat stat = PlayerStat.ITEMS_DROPPED; // Get player final Player player = event.getPlayer(); // Do general check if (!plugin.doGeneralCheck(player, stat)) return; PlayerStatSpecification specification = new ItemsDroppedSpecification(player.getUniqueId(), event.getItemDrop().getItemStack().getAmount(), player.getWorld().getName(), event.getItemDrop().getItemStack().getType()); // Update value to new stat. plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, specification.constructQuery()); }
Example #8
Source File: ItemTransferListener.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { if(this.ignoreNextDropEvent) { this.ignoreNextDropEvent = false; } else { // If the ignore flag is clear, this drop was caused by something other than // an inventory click (e.g. drop key, death, etc), so an event has not yet been fired int initialQuantity = event.getItemDrop().getItemStack().getAmount(); ItemStack stack = event.getItemDrop().getItemStack(); PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(event, ItemTransferEvent.Type.DROP, event.getPlayer(), Optional.of(new InventorySlot(event.getPlayer().getInventory())), Optional.empty(), stack, event.getItemDrop(), initialQuantity, event.getPlayer().getOpenInventory().getCursor()); this.callEvent(transferEvent); if(!transferEvent.isCancelled() && transferEvent.getQuantity() < initialQuantity) { int diff = initialQuantity - transferEvent.getQuantity(); stack.setAmount(stack.getAmount() - diff); stack = stack.clone(); stack.setAmount(diff); event.getPlayer().getInventory().addItem(stack); } } }
Example #9
Source File: EnhancedItemListener.java From EnchantmentsEnhance with GNU General Public License v3.0 | 6 votes |
/** * Prevents enhanced item from dropping. * * @param e */ @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onItemDrop(PlayerDropItemEvent e) { Item droppedItem = e.getItemDrop(); ItemStack DroppedItemStack = droppedItem.getItemStack(); Player p = e.getPlayer(); // Checks if the item is a bounded item if ((DroppedItemStack.hasItemMeta()) && (DroppedItemStack.getItemMeta() .getLore() != null)) { if (DroppedItemStack.getItemMeta().getLore().contains(Util.UNIQUEID + Util.toColor( SettingsManager.lang.getString("lore.untradeableLore")))) { e.setCancelled(true); Util.sendMessage(SettingsManager.lang.getString( "messages.noDrop"), p); } } }
Example #10
Source File: LanguageTests.java From Civs with GNU General Public License v3.0 | 6 votes |
@Test(expected = SuccessException.class) public void playerShouldNotBeAbleToDropItem() { RegionsTests.loadRegionTypeCobble(); Item item = mock(Item.class); ItemStack itemStack = mock(ItemStack.class); ItemMeta itemMeta = mock(ItemMeta.class); when(itemMeta.getDisplayName()).thenReturn("Cobble"); ArrayList<String> lore = new ArrayList<>(); lore.add(TestUtil.player.getUniqueId().toString()); lore.add("Civs Cobble"); when(itemStack.hasItemMeta()).thenReturn(true); when(itemMeta.getLore()).thenReturn(lore); when(itemStack.getItemMeta()).thenReturn(itemMeta); when(item.getItemStack()).thenReturn(itemStack); doThrow(new SuccessException()).when(item).remove(); PlayerDropItemEvent playerDropItemEvent = new PlayerDropItemEvent(TestUtil.player, item); CivilianListener civilianListener = new CivilianListener(); civilianListener.onCivilianDropItem(playerDropItemEvent); }
Example #11
Source File: KitLoading.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true) public void StopDrops(PlayerDropItemEvent event) { Player player = event.getPlayer(); Item item = event.getItemDrop(); if(item != null) { ItemStack stack = item.getItemStack(); if(stack != null) { if(KitUtils.isSoulbound(stack)) { player.playSound(player.getLocation(), Sound.BLAZE_HIT, 1.0F, 0.3F); event.getItemDrop().remove(); } } } }
Example #12
Source File: CustomItemManager.java From civcraft with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void OnPlayerDropItem(PlayerDropItemEvent event) { if (event.isCancelled()) { return; } ItemStack stack = event.getItemDrop().getItemStack(); if (LoreMaterial.isCustom(stack)) { LoreMaterial.getMaterial(stack).onItemDrop(event); } }
Example #13
Source File: ItemDropEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @SuppressWarnings("unused") public void onDropEvent(PlayerDropItemEvent event) { Player player = event.getPlayer(); if (!plugin.getWorldManager().isSkyWorld(player.getWorld())) { return; } if (!visitorsCanDrop && !plugin.playerIsOnIsland(player) && !plugin.playerIsInSpawn(player)) { event.setCancelled(true); plugin.notifyPlayer(player, tr("\u00a7eVisitors can't drop items!")); return; } addDropInfo(player, event.getItemDrop().getItemStack()); }
Example #14
Source File: GraphListener.java From LagMonitor with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onDrop(PlayerDropItemEvent dropItemEvent) { Item itemDrop = dropItemEvent.getItemDrop(); ItemStack mapItem = itemDrop.getItemStack(); if (isOurGraph(mapItem)) { mapItem.setAmount(0); } }
Example #15
Source File: LobbyListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerDropItem(final PlayerDropItemEvent e) { if (Util.get().isSpawnWorld(e.getPlayer().getWorld())) { if (!e.getPlayer().hasPermission("sw.alterlobby") && !SkyWarsReloaded.getIC().has(e.getPlayer())) { e.setCancelled(true); } } }
Example #16
Source File: BonusGoodieManager.java From civcraft with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void OnPlayerDropItemEvent(PlayerDropItemEvent event) { BonusGoodie goodie = CivGlobal.getBonusGoodie(event.getItemDrop().getItemStack()); if (goodie == null) { return; } // Verify that the player dropping this item is in fact our holder. // goodie.validateItem(event.getItemDrop().getItemStack(), null, event.getPlayer(), null); }
Example #17
Source File: UnitItemMaterial.java From civcraft with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public void onItemDrop(PlayerDropItemEvent event) { CivMessage.sendError(event.getPlayer(), "Cannot drop this item, belongs to the unit you are currently assigned."); event.setCancelled(true); event.getPlayer().updateInventory(); }
Example #18
Source File: SlimefunItemListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onItemDrop(PlayerDropItemEvent e) { for (ItemHandler handler : SlimefunItem.getPublicItemHandlers(ItemDropHandler.class)) { if (((ItemDropHandler) handler).onItemDrop(e, e.getPlayer(), e.getItemDrop())) { return; } } }
Example #19
Source File: BackpackListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onItemDrop(PlayerDropItemEvent e) { if (backpacks.containsKey(e.getPlayer().getUniqueId())) { ItemStack item = e.getItemDrop().getItemStack(); SlimefunItem sfItem = SlimefunItem.getByItem(item); if (sfItem instanceof SlimefunBackpack) { e.setCancelled(true); } } }
Example #20
Source File: TestBackpackListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Test public void testBackpackDropNormalItem() throws InterruptedException { Player player = server.addPlayer(); openMockBackpack(player, "DROP_NORMAL_ITEM_BACKPACK_TEST", 27); Item item = Mockito.mock(Item.class); Mockito.when(item.getItemStack()).thenReturn(new ItemStack(Material.SUGAR_CANE)); PlayerDropItemEvent event = new PlayerDropItemEvent(player, item); listener.onItemDrop(event); Assertions.assertFalse(event.isCancelled()); }
Example #21
Source File: ItemManager.java From HubBasics with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onDisable() { this.items.clear(); InventoryClickEvent.getHandlerList().unregister(itemListener); PlayerDropItemEvent.getHandlerList().unregister(itemListener); PlayerInteractEvent.getHandlerList().unregister(itemListener); }
Example #22
Source File: ItemListener.java From HubBasics with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onItemDrop(PlayerDropItemEvent event) { ItemStack currentItem = event.getItemDrop().getItemStack(); if (currentItem.getType() == Material.AIR) return; NBTItem nbtItem = new NBTItem(currentItem); if (!nbtItem.hasKey("HubBasics")) return; CustomItem item = HubBasics.getInstance().getItemManager().get(nbtItem.getString("HubBasics")); if (item == null) { currentItem.setType(Material.AIR); // Destroy old item return; } if (!item.getAllowDrop()) event.setCancelled(true); // Call setCancelled only when needed to not conflict with other plugins }
Example #23
Source File: PlayerDropCustomItem.java From AdditionsAPI with MIT License | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerDropCustomItemLowest(PlayerDropCustomItemEvent customEvent) { if (customEvent.isCancelled()) return; CustomItem cItem = customEvent.getCustomItem(); ItemPermissions perm = cItem.getPermissions(); PlayerDropItemEvent event = customEvent.getPlayerDropItemEvent(); if (!PermissionUtils.allowedAction(event.getPlayer(), perm.getType(), perm.getDrop())) event.setCancelled(true); }
Example #24
Source File: PlayerEventHandler.java From GriefDefender with MIT License | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerDropItem(PlayerDropItemEvent event) { final Player player = event.getPlayer(); GDCauseStackManager.getInstance().pushCause(player); if (!GDFlags.ITEM_DROP) { return; } final World world = event.getPlayer().getWorld(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.ITEM_DROP.getName(), player, world.getUID())) { return; } if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.ITEM_DROP.getName(), event.getItemDrop(), world.getUID())) { return; } final Location location = event.getItemDrop().getLocation(); final GDClaim targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location); if (GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.ITEM_DROP, player, event.getItemDrop(), player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) { event.setCancelled(true); } }
Example #25
Source File: GraphListener.java From LagMonitor with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onDrop(PlayerDropItemEvent dropItemEvent) { Item itemDrop = dropItemEvent.getItemDrop(); ItemStack mapItem = itemDrop.getItemStack(); if (isOurGraph(mapItem)) { mapItem.setAmount(0); } }
Example #26
Source File: PlayerDropItem.java From AdditionsAPI with MIT License | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerDropItem(PlayerDropItemEvent event) { if (event.isCancelled()) return; ItemStack item = event.getItemDrop().getItemStack(); if (!AdditionsAPI.isCustomItem(item)) return; CustomItemStack cStack = new CustomItemStack(item); Bukkit.getPluginManager().callEvent(new PlayerDropCustomItemEvent(event, cStack)); }
Example #27
Source File: PlayerDropItem.java From StaffPlus with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onDrop(PlayerDropItemEvent event) { UUID uuid = event.getPlayer().getUniqueId(); if((options.modeItemChange || !modeCoordinator.isInMode(uuid)) && !freezeHandler.isFrozen(uuid)) { return; } event.setCancelled(true); }
Example #28
Source File: Trade.java From TradePlus with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onDropItem(PlayerDropItemEvent event) { if (cancelled) return; if (player1.equals(event.getPlayer()) || player2.equals(event.getPlayer())) { event.setCancelled(true); if (accept1 && accept2) { giveOnCursor(event.getPlayer()); } } }
Example #29
Source File: PetOwnerListener.java From SonarPet with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onDropItem(PlayerDropItemEvent event) { if (event.getItemDrop().getItemStack().isSimilar(SelectorLayout.getSelectorItem()) && !(ConfigOptions.instance.getConfig().getBoolean("petSelector.allowDrop", true))) { event.setCancelled(true); event.getPlayer().updateInventory(); } }
Example #30
Source File: CustomBookOverlay.java From CS-CoreLib with GNU General Public License v3.0 | 5 votes |
public static void load(CSCoreLib plugin) { plugin.getServer().getPluginManager().registerEvents(new CustomBookOverlayListener(), plugin); plugin.getServer().getPluginManager().registerEvents(new Listener() { @EventHandler public void onDrop(PlayerDropItemEvent e) { if (opening.contains(e.getPlayer().getUniqueId())) e.setCancelled(true); } }, plugin); }