|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Inventory
Interface to the various inventories. Behavior relating to Material.AIR
is unspecified.
Method Summary | |
---|---|
HashMap<Integer,ItemStack> |
addItem(ItemStack... items)
Stores the given ItemStacks in the inventory. |
HashMap<Integer,? extends ItemStack> |
all(int materialId)
Returns a HashMap with all slots and ItemStacks in the inventory with given materialId. |
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 The HashMap contains entries where, the key is the slot index, and the value is the ItemStack in that slot. |
HashMap<Integer,? extends ItemStack> |
all(Material material)
Returns a HashMap with all slots and ItemStacks in the inventory with the given Material. |
void |
clear()
Clears out the whole Inventory. |
void |
clear(int index)
Clears out a particular slot in the index. |
boolean |
contains(int materialId)
Checks if the inventory contains any ItemStacks with the given materialId |
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(ItemStack item)
Checks if the inventory contains any ItemStacks matching the given ItemStack. |
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 |
contains(Material material)
Checks if the inventory contains any ItemStacks with the given material. |
boolean |
contains(Material material,
int amount)
Checks if the inventory contains any ItemStacks with the given material, adding to at least the minimum amount specified. |
boolean |
containsAtLeast(ItemStack item,
int amount)
Checks if the inventory contains any ItemStacks matching the given ItemStack and at least the minimum amount specified |
int |
first(int materialId)
Finds the first slot in the inventory containing an ItemStack with the given materialId. |
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 |
first(Material material)
Finds the first slot in the inventory containing an ItemStack with the given material |
int |
firstEmpty()
Returns the first empty Slot. |
ItemStack[] |
getContents()
Returns all ItemStacks from the inventory |
InventoryHolder |
getHolder()
Gets the block or entity belonging to the open inventory |
ItemStack |
getItem(int index)
Returns the ItemStack found in the slot at the given index |
int |
getMaxStackSize()
Returns the maximum stack size for an ItemStack in this inventory. |
String |
getName()
Returns the name of the inventory |
int |
getSize()
Returns the size of the inventory |
String |
getTitle()
Returns the title of this inventory. |
InventoryType |
getType()
Returns what type of inventory this is. |
List<HumanEntity> |
getViewers()
Gets a list of players viewing. |
ListIterator<ItemStack> |
iterator()
|
ListIterator<ItemStack> |
iterator(int index)
Returns an iterator starting at the given index. |
void |
remove(int materialId)
Removes all stacks in the inventory matching the given materialId. |
void |
remove(ItemStack item)
Removes all stacks in the inventory matching the given stack. |
void |
remove(Material material)
Removes all stacks in the inventory matching the given material. |
HashMap<Integer,ItemStack> |
removeItem(ItemStack... items)
Removes the given ItemStacks from the inventory. |
void |
setContents(ItemStack[] items)
Completely replaces the inventory's contents. |
void |
setItem(int index,
ItemStack item)
Stores the ItemStack at the given index of the inventory. |
void |
setMaxStackSize(int size)
This method allows you to change the maximum stack size for an inventory. |
Method Detail |
---|
int getSize()
int getMaxStackSize()
void setMaxStackSize(int size)
size
- The new maximum stack size for items in this inventory.String getName()
ItemStack getItem(int index)
index
- The index of the Slot's ItemStack to return
void setItem(int index, ItemStack item)
index
- The index where to put the ItemStackitem
- The ItemStack to setHashMap<Integer,ItemStack> addItem(ItemStack... items) throws IllegalArgumentException
items
- The ItemStacks to add
IllegalArgumentException
- if items or any element in it is nullHashMap<Integer,ItemStack> removeItem(ItemStack... items) throws IllegalArgumentException
items
- The ItemStacks to remove
IllegalArgumentException
- if items is nullItemStack[] getContents()
void setContents(ItemStack[] items) throws IllegalArgumentException
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.boolean contains(int materialId)
materialId
- The materialId to check for
boolean contains(Material material) throws IllegalArgumentException
material
- The material to check for
IllegalArgumentException
- if material is nullboolean contains(ItemStack item)
item
- The ItemStack to match against
boolean contains(int materialId, int amount)
materialId
- The materialId to check foramount
- The minimum amount to look for
boolean contains(Material material, int amount) throws IllegalArgumentException
material
- The material to check foramount
- The minimum amount
IllegalArgumentException
- if material is nullboolean contains(ItemStack item, int amount)
item
- The ItemStack to match againstamount
- The amount of stacks to find
boolean containsAtLeast(ItemStack item, int amount)
item
- The ItemStack to match againstamount
- The minimum amount
HashMap<Integer,? extends ItemStack> all(int materialId)
materialId
- The materialId to look for
HashMap<Integer,? extends ItemStack> all(Material material) throws IllegalArgumentException
material
- The material to look for
IllegalArgumentException
- if material is nullHashMap<Integer,? extends ItemStack> all(ItemStack item)
item
- The ItemStack to match against
int first(int materialId)
materialId
- The materialId to look for
int first(Material material) throws IllegalArgumentException
material
- The material to look for
IllegalArgumentException
- if material is nullint first(ItemStack item)
item
- The ItemStack to match against
int firstEmpty()
void remove(int materialId)
materialId
- The material to removevoid remove(Material material) throws IllegalArgumentException
material
- The material to remove
IllegalArgumentException
- if material is nullvoid remove(ItemStack item)
item
- The ItemStack to match againstvoid clear(int index)
index
- The index to empty.void clear()
List<HumanEntity> getViewers()
String getTitle()
InventoryType getType()
InventoryHolder getHolder()
ListIterator<ItemStack> iterator()
iterator
in interface Iterable<ItemStack>
ListIterator<ItemStack> iterator(int index)
index
- The index.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |