![]() |
Bukkit
1.4.7-R1.0
|
Interface to the various inventories. More...
Inheritance diagram for org.bukkit.inventory.Inventory:
Collaboration diagram for org.bukkit.inventory.Inventory:Public Member Functions | |
| int | getSize () |
| Returns the size of the inventory. | |
| int | getMaxStackSize () |
| Returns the maximum stack size for an ItemStack in this inventory. | |
| void | setMaxStackSize (int size) |
| This method allows you to change the maximum stack size for an inventory. | |
| String | getName () |
| Returns the name of the inventory. | |
| ItemStack | getItem (int index) |
| Returns the ItemStack found in the slot at the given index. | |
| void | setItem (int index, ItemStack item) |
| Stores the ItemStack at the given index of the inventory. | |
| HashMap< Integer, ItemStack > | addItem (ItemStack...items) throws IllegalArgumentException |
| Stores the given ItemStacks in the inventory. | |
| HashMap< Integer, ItemStack > | removeItem (ItemStack...items) throws IllegalArgumentException |
| Removes the given ItemStacks from the inventory. | |
| ItemStack[] | getContents () |
| Returns all ItemStacks from the inventory. | |
| void | setContents (ItemStack[] items) throws IllegalArgumentException |
| Completely replaces the inventory's contents. | |
| boolean | contains (int materialId) |
| Checks if the inventory contains any ItemStacks with the given materialId. | |
| boolean | contains (Material material) throws IllegalArgumentException |
| Checks if the inventory contains any ItemStacks with the given material. | |
| boolean | contains (ItemStack item) |
| Checks if the inventory contains any ItemStacks matching the given ItemStack. | |
| boolean | contains (int materialId, int amount) |
| Checks if the inventory contains any ItemStacks with the given materialId, adding to at least the minimum amount specified. | |
| boolean | contains (Material material, int amount) throws IllegalArgumentException |
| Checks if the inventory contains any ItemStacks with the given material, adding to at least the minimum amount specified. | |
| boolean | contains (ItemStack item, int amount) |
| Checks if the inventory contains any ItemStacks matching the given ItemStack and at least the minimum amount specified This will only match if both the type and the amount of the stack match. | |
| boolean | containsAtLeast (ItemStack item, int amount) |
| Returns a HashMap with all slots and ItemStacks in the inventory with given materialId. | |
| HashMap< Integer,?extends ItemStack > | all (int materialId) |
| Find all slots in the inventory containing any ItemStacks with the given materialId. | |
| HashMap< Integer,?extends ItemStack > | all (Material material) throws IllegalArgumentException |
| Returns a HashMap with all slots and ItemStacks in the inventory with the given Material. | |
| HashMap< Integer,?extends ItemStack > | all (ItemStack item) |
| Finds all slots in the inventory containing any ItemStacks with the given ItemStack This will only match slots if both the type and the amount of the stack match. | |
| int | first (int materialId) |
| Finds the first slot in the inventory containing an ItemStack with the given materialId. | |
| int | first (Material material) throws IllegalArgumentException |
| Finds the first slot in the inventory containing an ItemStack with the given material. | |
| int | first (ItemStack item) |
| Returns the first slot in the inventory containing an ItemStack with the given stack This will only match a slot if both the type and the amount of the stack match. | |
| int | firstEmpty () |
| Returns the first empty Slot. | |
| void | remove (int materialId) |
| Removes all stacks in the inventory matching the given materialId. | |
| void | remove (Material material) throws IllegalArgumentException |
| Removes all stacks in the inventory matching the given material. | |
| void | remove (ItemStack item) |
| Removes all stacks in the inventory matching the given stack. | |
| void | clear (int index) |
| Clears out a particular slot in the index. | |
| void | clear () |
| Clears out the whole Inventory. | |
| List< HumanEntity > | getViewers () |
| Gets a list of players viewing. | |
| String | getTitle () |
| Returns the title of this inventory. | |
| InventoryType | getType () |
| Returns what type of inventory this is. | |
| InventoryHolder | getHolder () |
| Gets the block or entity belonging to the open inventory. | |
| ListIterator< ItemStack > | iterator () |
| ListIterator< ItemStack > | iterator (int index) |
| Returns an iterator starting at the given index. | |
Interface to the various inventories.
Behavior relating to Material#AIR is unspecified.
Definition at line 14 of file Inventory.java.
| HashMap<Integer, ItemStack> org.bukkit.inventory.Inventory.addItem | ( | ItemStack... | items | ) | throws IllegalArgumentException |
Stores the given ItemStacks in the inventory.
This will try to fill existing stacks and empty slots as well as it can.
The returned HashMap contains what it couldn't store, where the key is the index of the parameter, and the value is the ItemStack at that index of the variadic parameter. If all items are stored, it will return an empty HashMap.
| items | The ItemStacks to add |
| IllegalArgumentException | if items or any element in it is null |
Referenced by org.bukkit.command.defaults.GiveCommand.execute().
| HashMap<Integer, ? extends ItemStack> org.bukkit.inventory.Inventory.all | ( | int | materialId | ) |
Find all slots in the inventory containing any ItemStacks with the given materialId.
| materialId | The materialId to look for |
| HashMap<Integer, ? extends ItemStack> org.bukkit.inventory.Inventory.all | ( | Material | material | ) | throws IllegalArgumentException |
Returns a HashMap with all slots and ItemStacks in the inventory with the given Material.
The HashMap contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack with the given Material is found, an empty map is returned.
| material | The material to look for |
| IllegalArgumentException | if material is null |
Finds all slots in the inventory containing any ItemStacks with the given ItemStack This will only match slots if both the type and the amount of the stack match.
The HashMap contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ImemStrack with the given Material is found, an empty map is returned.
| item | The ItemStack to match against |
| void org.bukkit.inventory.Inventory.clear | ( | int | index | ) |
Clears out a particular slot in the index.
| index | The index to empty. |
| void org.bukkit.inventory.Inventory.clear | ( | ) |
Clears out the whole Inventory.
| boolean org.bukkit.inventory.Inventory.contains | ( | int | materialId | ) |
Checks if the inventory contains any ItemStacks with the given materialId.
| materialId | The materialId to check for |
| boolean org.bukkit.inventory.Inventory.contains | ( | Material | material | ) | throws IllegalArgumentException |
| boolean org.bukkit.inventory.Inventory.contains | ( | ItemStack | item | ) |
| boolean org.bukkit.inventory.Inventory.contains | ( | int | materialId, |
| int | amount | ||
| ) |
Checks if the inventory contains any ItemStacks with the given materialId, adding to at least the minimum amount specified.
| materialId | The materialId to check for |
| amount | The minimum amount to look for |
| boolean org.bukkit.inventory.Inventory.contains | ( | Material | material, |
| int | amount | ||
| ) | throws IllegalArgumentException |
Checks if the inventory contains any ItemStacks with the given material, adding to at least the minimum amount specified.
| material | The material to check for |
| amount | The minimum amount |
| IllegalArgumentException | if material is null |
| boolean org.bukkit.inventory.Inventory.contains | ( | ItemStack | item, |
| int | amount | ||
| ) |
Checks if the inventory contains any ItemStacks matching the given ItemStack and at least the minimum amount specified This will only match if both the type and the amount of the stack match.
| item | The ItemStack to match against |
| amount | The amount of stacks to find |
| boolean org.bukkit.inventory.Inventory.containsAtLeast | ( | ItemStack | item, |
| int | amount | ||
| ) |
Returns a HashMap with all slots and ItemStacks in the inventory with given materialId.
The HashMap contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack with the given materialId is found, an empty map is returned.
| item | The ItemStack to match against |
| amount | The minimum amount |
| int org.bukkit.inventory.Inventory.first | ( | int | materialId | ) |
Finds the first slot in the inventory containing an ItemStack with the given materialId.
| materialId | The materialId to look for |
| int org.bukkit.inventory.Inventory.first | ( | Material | material | ) | throws IllegalArgumentException |
| int org.bukkit.inventory.Inventory.first | ( | ItemStack | item | ) |
| int org.bukkit.inventory.Inventory.firstEmpty | ( | ) |
Returns the first empty Slot.
| ItemStack [] org.bukkit.inventory.Inventory.getContents | ( | ) |
Returns all ItemStacks from the inventory.
| InventoryHolder org.bukkit.inventory.Inventory.getHolder | ( | ) |
Gets the block or entity belonging to the open inventory.
Referenced by org.bukkit.block.DoubleChest.getLeftSide(), and org.bukkit.block.DoubleChest.getRightSide().
| ItemStack org.bukkit.inventory.Inventory.getItem | ( | int | index | ) |
Returns the ItemStack found in the slot at the given index.
| index | The index of the Slot's ItemStack to return |
Referenced by org.bukkit.inventory.InventoryView.getItem().
| int org.bukkit.inventory.Inventory.getMaxStackSize | ( | ) |
| String org.bukkit.inventory.Inventory.getName | ( | ) |
Returns the name of the inventory.
| int org.bukkit.inventory.Inventory.getSize | ( | ) |
Returns the size of the inventory.
Referenced by org.bukkit.inventory.InventoryView.convertSlot(), and org.bukkit.inventory.InventoryView.countSlots().
| String org.bukkit.inventory.Inventory.getTitle | ( | ) |
Returns the title of this inventory.
Referenced by org.bukkit.inventory.InventoryView.getTitle().
| InventoryType org.bukkit.inventory.Inventory.getType | ( | ) |
Returns what type of inventory this is.
| List<HumanEntity> org.bukkit.inventory.Inventory.getViewers | ( | ) |
Gets a list of players viewing.
Note that a player is considered to be viewing their own inventory and internal crafting screen even when said inventory is not open. They will normally be considered to be viewing their inventory even when they have a different inventory screen open, but it's possible for customized inventory screens to exclude the viewer's inventory, so this should never be assumed to be non-empty.
Referenced by org.bukkit.event.inventory.InventoryEvent.getViewers().
| ListIterator<ItemStack> org.bukkit.inventory.Inventory.iterator | ( | ) |
| ListIterator<ItemStack> org.bukkit.inventory.Inventory.iterator | ( | int | index | ) |
Returns an iterator starting at the given index.
If the index is positive, then the first call to next() will return the item at that index; if it is negative, the first call to previous will return the item at index (getSize() + index).
| index | The index. |
| void org.bukkit.inventory.Inventory.remove | ( | int | materialId | ) |
Removes all stacks in the inventory matching the given materialId.
| materialId | The material to remove |
| void org.bukkit.inventory.Inventory.remove | ( | Material | material | ) | throws IllegalArgumentException |
Removes all stacks in the inventory matching the given material.
| material | The material to remove |
| IllegalArgumentException | if material is null |
| void org.bukkit.inventory.Inventory.remove | ( | ItemStack | item | ) |
Removes all stacks in the inventory matching the given stack.
This will only match a slot if both the type and the amount of the stack match
| item | The ItemStack to match against |
| HashMap<Integer, ItemStack> org.bukkit.inventory.Inventory.removeItem | ( | ItemStack... | items | ) | throws IllegalArgumentException |
Removes the given ItemStacks from the inventory.
It will try to remove 'as much as possible' from the types and amounts you give as arguments.
The returned HashMap contains what it couldn't remove, where the key is the index of the parameter, and the value is the ItemStack at that index of the variadic parameter. If all the given ItemStacks are removed, it will return an empty HashMap.
| items | The ItemStacks to remove |
| IllegalArgumentException | if items is null |
| void org.bukkit.inventory.Inventory.setContents | ( | ItemStack[] | items | ) | throws IllegalArgumentException |
Completely replaces the inventory's contents.
Removes all existing contents and replaces it with the ItemStacks given in the array.
| items | A complete replacement for the contents; the length must be less than or equal to getSize(). |
| IllegalArgumentException | If the array has more items than the inventory. |
| void org.bukkit.inventory.Inventory.setItem | ( | int | index, |
| ItemStack | item | ||
| ) |
Stores the ItemStack at the given index of the inventory.
Referenced by org.bukkit.inventory.InventoryView.setItem().
| void org.bukkit.inventory.Inventory.setMaxStackSize | ( | int | size | ) |
This method allows you to change the maximum stack size for an inventory.
Caveats:
| size | The new maximum stack size for items in this inventory. |