org.bukkit.event.inventory.InventoryCreativeEvent Java Examples
The following examples show how to use
org.bukkit.event.inventory.InventoryCreativeEvent.
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: KitMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onInventoryClick(final InventoryClickEvent event) { if (event instanceof InventoryCreativeEvent || event.getWhoClicked() != event.getInventory().getHolder() || !ArmorType.isArmorSlot(event.getSlot())) { return; } MatchPlayer player = this.match.getPlayer((Player) event.getWhoClicked()); if (player == null || !this.lockedArmorSlots.containsEntry( player, ArmorType.byInventorySlot(event.getSlot()))) { return; } switch (event.getAction()) { case PICKUP_ALL: case PICKUP_HALF: case PICKUP_SOME: case PICKUP_ONE: case SWAP_WITH_CURSOR: case MOVE_TO_OTHER_INVENTORY: case DROP_ONE_SLOT: case DROP_ALL_SLOT: case HOTBAR_SWAP: case HOTBAR_MOVE_AND_READD: case COLLECT_TO_CURSOR: event.setCancelled(true); player.sendWarning("This piece of armor cannot be removed", true); break; } }
Example #2
Source File: ItemSharingAndLockingListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onInventoryClick(final InventoryClickEvent event) { if(event instanceof InventoryCreativeEvent) return;; // Ensure the player is clicking in their own inventory // TODO: should we allow items to be locked into other types of inventories? if(!Objects.equals(event.getWhoClicked(), event.getInventory().getHolder())) return; // Break out of the switch if the action will move a locked item, otherwise return switch(event.getAction()) { case HOTBAR_SWAP: case HOTBAR_MOVE_AND_READD: // These actions can move up to two stacks. Check the hotbar stack, // and then fall through to check the stack under the cursor. if(isLocked(Slot.Hotbar.forPosition(event.getHotbarButton()) .getItem(event.getWhoClicked().getInventory()))) break; // fall through case PICKUP_ALL: case PICKUP_HALF: case PICKUP_SOME: case PICKUP_ONE: case SWAP_WITH_CURSOR: case MOVE_TO_OTHER_INVENTORY: case DROP_ONE_SLOT: case DROP_ALL_SLOT: case COLLECT_TO_CURSOR: // All these actions move only a single stack, except COLLECT_TO_CURSOR, // which can only move items that are stackable with the one under the cursor, // and locked items are only stackable with other locked items. if(isLocked(event.getCurrentItem())) break; // fall through default: return; } event.setCancelled(true); sendLockWarning(event.getWhoClicked()); }
Example #3
Source File: WorldInventoriesDupingPatch.java From PerWorldInventory with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onCreativeSlotChange(InventoryCreativeEvent event) { if (timeouts.isEmpty()) { return; // Saves performance for most common case } InventoryHolder holder = event.getInventory().getHolder(); if (holder instanceof Player && timeouts.containsKey(((Player) holder).getUniqueId())) { event.setResult(Event.Result.DENY); } }
Example #4
Source File: WorldInventoriesDupingPatch.java From PerWorldInventory with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onCreativeSlotChange(InventoryCreativeEvent event) { if (timeouts.isEmpty()) { return; // Saves performance for most common case } InventoryHolder holder = event.getInventory().getHolder(); if (holder instanceof Player && timeouts.containsKey(((Player) holder).getUniqueId())) { event.setResult(Event.Result.DENY); } }
Example #5
Source File: CEListener.java From ce with GNU Lesser General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void inventoryMenuPrevention(InventoryCreativeEvent event) { if (event.getView().getTopInventory().getTitle().startsWith("CE")) event.setCancelled(true); }
Example #6
Source File: ObserverModule.java From CardinalPGM with MIT License | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onViewingInventoryClick(InventoryCreativeEvent event) { updateNextTick(event.getActor()); }