Java Code Examples for org.bukkit.inventory.Inventory#getType()
The following examples show how to use
org.bukkit.inventory.Inventory#getType() .
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: CraftContainer.java From Kettle with GNU General Public License v3.0 | 6 votes |
public CraftContainer(final Inventory inventory, final EntityPlayer player, int id) { this(new InventoryView() { @Override public Inventory getTopInventory() { return inventory; } @Override public Inventory getBottomInventory() { return getPlayer().getInventory(); } @Override public HumanEntity getPlayer() { return player.getBukkitEntity(); } @Override public InventoryType getType() { return inventory.getType(); } }, player, id); }
Example 2
Source File: CraftContainer.java From Thermos with GNU General Public License v3.0 | 6 votes |
public CraftContainer(final Inventory inventory, final HumanEntity player, int id) { this(new InventoryView() { @Override public Inventory getTopInventory() { return inventory; } @Override public Inventory getBottomInventory() { return player.getInventory(); } @Override public HumanEntity getPlayer() { return player; } @Override public InventoryType getType() { return inventory.getType(); } }, id); }
Example 3
Source File: InventoryUtils.java From NovaGuilds with GNU General Public License v3.0 | 6 votes |
/** * Gets a list of missing items * * @param inventory inventory * @param items list of items * @return list of missing items */ public static List<ItemStack> getMissingItems(Inventory inventory, List<ItemStack> items) { final List<ItemStack> missing = new ArrayList<>(); if(items != null && inventory.getType() != InventoryType.CREATIVE) { for(ItemStack item : items) { if(!containsAtLeast(inventory, item, item.getAmount())) { ItemStack missingItemStack = item.clone(); missingItemStack.setAmount(item.getAmount() - getTotalAmountOfItemStackInInventory(inventory, item)); missing.add(missingItemStack); } } } return missing; }
Example 4
Source File: SilentOpenChest.java From SuperVanish with Mozilla Public License 2.0 | 5 votes |
private boolean isShulkerBox(Inventory inv) { try { return inv.getType() == InventoryType.SHULKER_BOX; } catch (NoSuchFieldError e) { return false; } }
Example 5
Source File: VanillaMachinesListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onPreBrew(InventoryClickEvent e) { Inventory inventory = e.getInventory(); if (inventory.getType() == InventoryType.BREWING && e.getRawSlot() < inventory.getSize() && inventory.getHolder() instanceof BrewingStand) { e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCursor()))); } }
Example 6
Source File: InventoryForItemStorage.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
@Override protected void inventoryClick(InventoryClickEvent event) { Inventory inventory = event.getClickedInventory(); if (inventory != null) { InventoryAction action = event.getAction(); if (action == InventoryAction.COLLECT_TO_CURSOR) { event.setCancelled(true); } else if (inventory.getType() == InventoryType.PLAYER) { if (action == InventoryAction.MOVE_TO_OTHER_INVENTORY) { event.setCancelled(true); } } else { event.setCancelled(true); int slot = event.getSlot(); if (slot < ITEMS_PER_PAGE) { if (event.getCursor().getType() == Material.AIR && _originaItems[slot] != null) { event.getView().setCursor(_originaItems[slot]); } } else if (slot == 52) { // previous page changePage(-1); } else if (slot == 53) { // next page changePage(1); } } } }
Example 7
Source File: TrMenuNmsModern.java From TrMenu with MIT License | 4 votes |
private Containers<?> getByInventory(Inventory inventory) { InventoryType type = inventory.getType(); int size = inventory.getSize(); if (type == InventoryType.CHEST) { if (size == 9) { return Containers.GENERIC_9X1; } else if (size == 18) { return Containers.GENERIC_9X2; } else if (size == 27) { return Containers.GENERIC_9X3; } else if (size == 36) { return Containers.GENERIC_9X4; } else if (size == 45) { return Containers.GENERIC_9X5; } else { return Containers.GENERIC_9X6; } } else if (type == InventoryType.DROPPER || type == InventoryType.DISPENSER) { return Containers.GENERIC_3X3; } else if (type == InventoryType.BARREL || type == InventoryType.ENDER_CHEST) { return Containers.GENERIC_9X3; } else if (type == InventoryType.CRAFTING || type == InventoryType.WORKBENCH) { return Containers.CRAFTING; } else if (type == InventoryType.HOPPER) { return Containers.HOPPER; } else if (type == InventoryType.LOOM) { return Containers.LOOM; } else if (type == InventoryType.ANVIL) { return Containers.ANVIL; } else if (type == InventoryType.BEACON) { return Containers.BEACON; } else if (type == InventoryType.SMOKER) { return Containers.SMOKER; } else if (type == InventoryType.BREWING) { return Containers.BREWING_STAND; } else if (type == InventoryType.FURNACE) { return Containers.FURNACE; } else if (type == InventoryType.LECTERN) { return Containers.LECTERN; } else if (type == InventoryType.MERCHANT) { return Containers.MERCHANT; } else if (type == InventoryType.ENCHANTING) { return Containers.ENCHANTMENT; } else if (type == InventoryType.GRINDSTONE) { return Containers.GRINDSTONE; } else if (type == InventoryType.CARTOGRAPHY) { return Containers.CARTOGRAPHY_TABLE; } else if (type == InventoryType.SHULKER_BOX) { return Containers.SHULKER_BOX; } else if (type == InventoryType.STONECUTTER) { return Containers.STONECUTTER; } else if (type == InventoryType.BLAST_FURNACE) { return Containers.BLAST_FURNACE; } else { return Containers.GENERIC_3X3; } }