org.bukkit.event.inventory.InventoryMoveItemEvent Java Examples
The following examples show how to use
org.bukkit.event.inventory.InventoryMoveItemEvent.
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: BlockListeners.java From CratesPlus with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onInventoryMove(InventoryMoveItemEvent event) { if (!cratesPlus.getConfigHandler().isDisableKeySwapping()) return; String title; ItemStack item = event.getItem(); 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)) { // Send message? event.setCancelled(true); return; } } }
Example #2
Source File: BlockListener.java From QuickShop-Reremake with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onInventoryMove(InventoryMoveItemEvent event) { if (!super.getPlugin().getConfig().getBoolean("shop.update-sign-when-inventory-moving", true)) { return; } final Inventory inventory = event.getDestination(); final Location location = inventory.getLocation(); if (location == null) { return; } // Delayed task. Event triggers when item is moved, not when it is received. final Shop shop = getShopRedstone(location, true); if (shop != null) { super.getPlugin().getSignUpdateWatcher().scheduleSignUpdate(shop); } }
Example #3
Source File: ShopUpdateListener.java From ShopChest with MIT License | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onInventoryUpdate(InventoryMoveItemEvent e) { if (!plugin.getHologramFormat().isDynamic()) return; Location loc = null; if (e.getSource().getHolder() instanceof Chest) { loc = ((Chest) e.getSource().getHolder()).getLocation(); } else if (e.getSource().getHolder() instanceof DoubleChest) { loc = ((DoubleChest) e.getSource().getHolder()).getLocation(); } else if (e.getDestination().getHolder() instanceof Chest) { loc = ((Chest) e.getDestination().getHolder()).getLocation(); } else if (e.getDestination().getHolder() instanceof DoubleChest) { loc = ((DoubleChest) e.getDestination().getHolder()).getLocation(); } if (loc != null) { Shop shop = plugin.getShopUtils().getShop(loc); if (shop != null) shop.updateHologramText(); } }
Example #4
Source File: LWCPlayerListener.java From Modern-LWC with MIT License | 6 votes |
@EventHandler(ignoreCancelled = true) public void onMoveItem(InventoryMoveItemEvent event) { boolean result; // if the initiator is the same as the source it is a dropper i.e. // depositing items if (event.getInitiator() == event.getSource()) { result = handleMoveItemEvent(event.getInitiator(), event.getDestination()); } else { result = handleMoveItemEvent(event.getInitiator(), event.getSource()); } if (result) { event.setCancelled(true); } }
Example #5
Source File: ChestProtectListener.java From ShopChest with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onItemMove(InventoryMoveItemEvent e) { if ((e.getSource().getType().equals(InventoryType.CHEST)) && (!e.getInitiator().getType().equals(InventoryType.PLAYER))) { if (e.getSource().getHolder() instanceof DoubleChest) { DoubleChest dc = (DoubleChest) e.getSource().getHolder(); Chest r = (Chest) dc.getRightSide(); Chest l = (Chest) dc.getLeftSide(); if (shopUtils.isShop(r.getLocation()) || shopUtils.isShop(l.getLocation())) e.setCancelled(true); } else if (e.getSource().getHolder() instanceof Chest) { Chest c = (Chest) e.getSource().getHolder(); if (shopUtils.isShop(c.getLocation())) e.setCancelled(true); } } }
Example #6
Source File: BlockEventHandler.java From GriefDefender with MIT License | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) { if (!GDFlags.INVENTORY_ITEM_MOVE || !GriefDefenderPlugin.getGlobalConfig().getConfig().economy.rentSystem) { return; } final World world = event.getSource().getLocation().getWorld(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID()) || GriefDefenderPlugin.getInstance().getVaultProvider() == null) { return; } final Inventory sourceInventory = event.getSource(); final Inventory targetInventory = event.getDestination(); final Location sourceLocation = sourceInventory.getLocation(); final Location targetLocation = targetInventory.getLocation(); final GDClaim sourceClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(sourceLocation); final GDClaim targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(targetLocation); if (sourceClaim.isWilderness() && targetClaim.isWilderness() || (GriefDefenderPlugin.getInstance().getVaultProvider() == null)) { return; } if (sourceClaim.getEconomyData().isRented() || targetClaim.getEconomyData().isRented()) { event.setCancelled(true); return; } }
Example #7
Source File: CivilianListener.java From Civs with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onInventoryMoveEvent(InventoryMoveItemEvent event) { if (ConfigManager.getInstance().getAllowSharingCivsItems()) { return; } if (!CVItem.isCivsItem(event.getItem())) { return; } if (!(event.getDestination() instanceof PlayerInventory)) { event.setCancelled(true); if (!event.getSource().getViewers().isEmpty()) { HumanEntity humanEntity = event.getSource().getViewers().get(0); humanEntity.sendMessage(Civs.getPrefix() + LocaleManager.getInstance().getTranslationWithPlaceholders((Player) humanEntity, LocaleConstants.PREVENT_CIVS_ITEM_SHARE)); } } }
Example #8
Source File: QAListener.java From QualityArmory with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onHopper(InventoryMoveItemEvent e) { if (e.isCancelled()) return; if (e.getSource().getType() == InventoryType.HOPPER || e.getSource().getType() == InventoryType.DISPENSER || e.getSource().getType() == InventoryType.DROPPER) if (QualityArmory.isGun(e.getItem())) e.setCancelled(true); }
Example #9
Source File: ChestProtectListener.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) void onInventoryMoveItem(InventoryMoveItemEvent event) { if (event.getSource() != null) { InventoryHolder holder = event.getSource().getHolder(); if (holder != null && holder instanceof Chest) { Block block = ((Chest) holder).getBlock(); if (plugin.getProtectedChests().isChestProtected(block, null)) { event.setCancelled(true); } } } }
Example #10
Source File: ItemFilter.java From Minepacks with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemMove(InventoryMoveItemEvent event) { if(event.getDestination().getHolder() instanceof Backpack && isItemBlocked(event.getItem())) { if(event.getSource().getHolder() instanceof Player) { sendNotAllowedMessage((Player) event.getSource().getHolder(), event.getItem()); } event.setCancelled(true); } }
Example #11
Source File: CreativeModeListener.java From ShopChest with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onInventoryMove(InventoryMoveItemEvent e) { // Cancel any inventory movement if SelectClickType is set if (e.getSource().getHolder() instanceof Player) { Player p = (Player) e.getSource().getHolder(); ClickType clickType = ClickType.getPlayerClickType(p); if (clickType instanceof SelectClickType) e.setCancelled(true); } }
Example #12
Source File: PotionFuelsListener.java From UHC with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true) public void on(InventoryMoveItemEvent event) { if (event.getDestination().getType() != InventoryType.BREWING) return; if (disabled.contains(event.getItem().getType())) { event.setCancelled(true); } }
Example #13
Source File: ATM.java From TimeIsMoney with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onMove(InventoryMoveItemEvent e) { if (e.getSource() == null || e.getSource().getViewers().size() == 0 || e.getSource().getViewers().get(0).getOpenInventory() == null) return; if (openATMs.contains(e.getSource().getViewers().get(0).getOpenInventory().getTopInventory())) { e.setCancelled(true); } }
Example #14
Source File: InventoryGui.java From InventoryGui with MIT License | 5 votes |
public void unregister() { InventoryClickEvent.getHandlerList().unregister(this); InventoryDragEvent.getHandlerList().unregister(this); InventoryCloseEvent.getHandlerList().unregister(this); InventoryMoveItemEvent.getHandlerList().unregister(this); BlockDispenseEvent.getHandlerList().unregister(this); BlockBreakEvent.getHandlerList().unregister(this); EntityDeathEvent.getHandlerList().unregister(this); }
Example #15
Source File: CO2Listener.java From GlobalWarming with GNU Lesser General Public License v3.0 | 5 votes |
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) { if (event.getItem().getType().isFuel()) { if (event.getDestination() instanceof FurnaceInventory) { FurnaceInventory furnaceInventory = (FurnaceInventory) event.getDestination(); } } }
Example #16
Source File: ShopProtectionListener.java From QuickShop-Reremake with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onInventoryMove(InventoryMoveItemEvent event) { if (!plugin.getConfig().getBoolean("protect.hopper")) { return; } final Location loc = event.getSource().getLocation(); if (loc == null) { return; } final Shop shop = getShopRedstone(loc, true); if (shop == null) { return; } event.setCancelled(true); final Location location = event.getInitiator().getLocation(); if (location == null) { return; } final InventoryHolder holder = event.getInitiator().getHolder(); if (holder instanceof Entity) { ((Entity) holder).remove(); } else if (holder instanceof Block) { location.getBlock().breakNaturally(); } else { Util.debugLog("Unknown location = " + loc); } if (sendProtectionAlert) { MsgUtil.sendGlobalAlert("[DisplayGuard] Defened a item steal action at" + location); } }
Example #17
Source File: WoolMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onItemTransfer(InventoryMoveItemEvent event) { // When a hopper or dispenser transfers an item, register both blocks involved this.registerContainer(event.getSource()); this.registerContainer(event.getDestination()); }
Example #18
Source File: InventoryGui.java From InventoryGui with MIT License | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onInventoryMoveItem(InventoryMoveItemEvent event) { if (hasRealOwner() && (owner.equals(event.getDestination().getHolder()) || owner.equals(event.getSource().getHolder()))) { plugin.getServer().getScheduler().runTask(plugin, (Runnable) gui::draw); } }
Example #19
Source File: CustomInventoryListener.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true) public void invEvent(InventoryMoveItemEvent e) { if (e.getDestination().getHolder() instanceof QuickShopPreviewInventoryHolder || e.getSource().getHolder() instanceof QuickShopPreviewInventoryHolder) { e.setCancelled(true); } }
Example #20
Source File: WoolMatchModule.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onItemTransfer(InventoryMoveItemEvent event) { // When a hopper or dispenser transfers an item, register both blocks involved this.registerContainer(event.getSource()); this.registerContainer(event.getDestination()); }