Package net.glowstone.inventory
Class GlowInventory
java.lang.Object
net.glowstone.inventory.GlowInventory
- All Implemented Interfaces:
 Iterable<org.bukkit.inventory.ItemStack>,org.bukkit.inventory.Inventory
- Direct Known Subclasses:
 GlowAnvilInventory,GlowBeaconInventory,GlowBrewerInventory,GlowChestInventory,GlowCraftingInventory,GlowEnchantingInventory,GlowFurnaceInventory,GlowHorseInventory,GlowLlamaInventory,GlowMerchantInventory,GlowPlayerInventory,GlowSuperInventory
A class which represents an inventory.
- 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGlowInventory(org.bukkit.inventory.InventoryHolder holder, org.bukkit.event.inventory.InventoryType type) GlowInventory(org.bukkit.inventory.InventoryHolder holder, org.bukkit.event.inventory.InventoryType type, int size) GlowInventory(org.bukkit.inventory.InventoryHolder holder, org.bukkit.event.inventory.InventoryType type, int size, String title)  - 
Method Summary
Modifier and TypeMethodDescriptionaddItem(org.bukkit.inventory.ItemStack... items) org.bukkit.inventory.ItemStackaddItemStack(org.bukkit.inventory.ItemStack item, boolean ignoreMeta) Adds the contents of the given ItemStack to the inventory.voidaddViewer(org.bukkit.entity.HumanEntity viewer) Add a viewer to the inventory.all(@NotNull org.bukkit.Material material) all(org.bukkit.inventory.ItemStack item) voidclear()voidclear(int index) intclose()intconsumeItem(int slot) Consumes an item in the given slot.intconsumeItem(int slot, boolean wholeStack) Consumes an item or the full stack in the given slot.booleancontains(@NotNull org.bukkit.Material material) booleancontains(@NotNull org.bukkit.Material material, int amount) booleancontains(org.bukkit.inventory.ItemStack item) booleancontains(org.bukkit.inventory.ItemStack item, int amount) booleancontainsAtLeast(org.bukkit.inventory.ItemStack item, int amount) intfirst(@NotNull org.bukkit.inventory.ItemStack item) intfirst(@NotNull org.bukkit.Material material) intorg.bukkit.inventory.ItemStack @NotNull []org.bukkit.inventory.InventoryHolderThe owner of this inventory.@Nullable org.bukkit.inventory.InventoryHoldergetHolder(boolean snapshotBlockEntity) @NotNull org.bukkit.inventory.ItemStackgetItem(int index) org.bukkit.LocationintThe inventory's maximum stack size.intGets the number of slots in this inventory according to the protocol.intgetSize()getSlot(int slot) Returns a certain slot.getSlots()Returns the whole slot list.org.bukkit.event.inventory.InventoryType.SlotTypegetSlotType(int slot) Get the type of the specified slot.org.bukkit.inventory.ItemStack[]getTitle()The inventory's name.org.bukkit.event.inventory.InventoryTypegetType()The type of this inventory.@NotNull List<org.bukkit.entity.HumanEntity>Set<org.bukkit.entity.HumanEntity>Returns the set which contains viewers.voidhandleShiftClick(GlowPlayer player, org.bukkit.inventory.InventoryView view, int clickedSlot, org.bukkit.inventory.ItemStack clickedItem) Handle a shift click in this inventory by the specified player.protected voidinitialize(List<GlowInventorySlot> slots, Set<org.bukkit.entity.HumanEntity> viewers, org.bukkit.inventory.InventoryHolder owner, org.bukkit.event.inventory.InventoryType type, String title) Initializes some key components of this inventory.booleanisEmpty()booleanitemPlaceAllowed(int slot, org.bukkit.inventory.ItemStack stack) Check whether it is allowed for a player to insert the given ItemStack at the slot, regardless of the slot's current contents.booleanitemShiftClickAllowed(int slot, org.bukkit.inventory.ItemStack stack) Check whether, in a shift-click operation, an item of the specified type may be placed in the given slot.@NotNull ListIterator<org.bukkit.inventory.ItemStack>iterator()@NotNull ListIterator<org.bukkit.inventory.ItemStack>iterator(int index) voidremove(@NotNull org.bukkit.inventory.ItemStack item) voidremove(@NotNull org.bukkit.Material material) removeItem(org.bukkit.inventory.ItemStack... items) removeItemAnySlot(@NotNull org.bukkit.inventory.ItemStack... items) org.bukkit.inventory.ItemStackremoveItemStack(org.bukkit.inventory.ItemStack item, boolean ignoreMeta) Removes the given ItemStack from the inventory.voidremoveViewer(org.bukkit.entity.HumanEntity viewer) Remove a viewer from the inventory.voidsetContents(org.bukkit.inventory.ItemStack[] items) voidsetItem(int index, org.bukkit.inventory.ItemStack item) voidsetMaxStackSize(int maxStackSize) The inventory's maximum stack size.voidsetStorageContents(org.bukkit.inventory.ItemStack[] items) voidSet the custom title of this inventory or reset it to the default.toString()org.bukkit.inventory.ItemStacktryToFillSlots(org.bukkit.inventory.ItemStack stack, int... slots) Tries to put the given items into the specified slots of this inventory from the start slot (inclusive) to the end slot (exclusive).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator 
- 
Constructor Details
- 
GlowInventory
protected GlowInventory() - 
GlowInventory
public GlowInventory(org.bukkit.inventory.InventoryHolder holder, org.bukkit.event.inventory.InventoryType type)  - 
GlowInventory
public GlowInventory(org.bukkit.inventory.InventoryHolder holder, org.bukkit.event.inventory.InventoryType type, int size)  - 
GlowInventory
public GlowInventory(org.bukkit.inventory.InventoryHolder holder, org.bukkit.event.inventory.InventoryType type, int size, String title)  
 - 
 - 
Method Details
- 
removeItemAnySlot
@NotNull public @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack> removeItemAnySlot(@NotNull @NotNull org.bukkit.inventory.ItemStack... items) throws IllegalArgumentException - Specified by:
 removeItemAnySlotin interfaceorg.bukkit.inventory.Inventory- Throws:
 IllegalArgumentException
 - 
initialize
protected void initialize(List<GlowInventorySlot> slots, Set<org.bukkit.entity.HumanEntity> viewers, org.bukkit.inventory.InventoryHolder owner, org.bukkit.event.inventory.InventoryType type, String title) Initializes some key components of this inventory.This should be called in the constructor.
- Parameters:
 slots- List of slots this inventory has.viewers- Set for storage of current inventory viewers.owner- InventoryHolder which owns this Inventory.type- The inventory type.title- Inventory title, displayed in the client.
 - 
addViewer
public void addViewer(org.bukkit.entity.HumanEntity viewer) Add a viewer to the inventory.- Parameters:
 viewer- The HumanEntity to add.
 - 
removeViewer
public void removeViewer(org.bukkit.entity.HumanEntity viewer) Remove a viewer from the inventory.- Parameters:
 viewer- The HumanEntity to remove.
 - 
getViewersSet
Returns the set which contains viewers.- Returns:
 - Viewers set.
 
 - 
getSlot
Returns a certain slot.- Parameters:
 slot- index.- Returns:
 - The requested slot.
 
 - 
getSlotType
public org.bukkit.event.inventory.InventoryType.SlotType getSlotType(int slot) Get the type of the specified slot.- Parameters:
 slot- The slot number.- Returns:
 - The SlotType of the slot.
 
 - 
itemPlaceAllowed
public boolean itemPlaceAllowed(int slot, org.bukkit.inventory.ItemStack stack) Check whether it is allowed for a player to insert the given ItemStack at the slot, regardless of the slot's current contents.Should return false for crafting output slots or armor slots which cannot accept the given item.
- Parameters:
 slot- The slot number.stack- The stack to add.- Returns:
 - Whether the stack can be added there.
 
 - 
itemShiftClickAllowed
public boolean itemShiftClickAllowed(int slot, org.bukkit.inventory.ItemStack stack) Check whether, in a shift-click operation, an item of the specified type may be placed in the given slot.- Parameters:
 slot- The slot number.stack- The stack to add.- Returns:
 - Whether the stack can be added there.
 
 - 
handleShiftClick
public void handleShiftClick(GlowPlayer player, org.bukkit.inventory.InventoryView view, int clickedSlot, org.bukkit.inventory.ItemStack clickedItem) Handle a shift click in this inventory by the specified player.The default implementation distributes items from the right to the left and from the bottom to the top.
- Parameters:
 player- The player who clickedview- The inventory view in which was clickedclickedSlot- The slot in the viewclickedItem- The item at which was clicked
 - 
tryToFillSlots
public org.bukkit.inventory.ItemStack tryToFillSlots(org.bukkit.inventory.ItemStack stack, int... slots) Tries to put the given items into the specified slots of this inventory from the start slot (inclusive) to the end slot (exclusive).The slots are supplied in pairs, first the start then the end slots.
This will first try to fill up all partial slots and if items are still left after doing so, it places them into the first empty slot.
If no empty slot was found and there are still items left, they're returned from this method.
- Parameters:
 stack- The items to place downslots- Pairs of start/end slots- Returns:
 - The remaining items or 
nullif non are remaining 
 - 
getRawSlots
public int getRawSlots()Gets the number of slots in this inventory according to the protocol.Some inventories have 0 slots in the protocol, despite having slots.
- Returns:
 - The numbers of slots
 
 - 
getSize
public int getSize()- Specified by:
 getSizein interfaceorg.bukkit.inventory.Inventory
 - 
getSlots
Returns the whole slot list.- Returns:
 - Slot list.
 
 - 
setTitle
Set the custom title of this inventory or reset it to the default.- Parameters:
 title- The new title, or null to reset.
 - 
getViewers
- Specified by:
 getViewersin interfaceorg.bukkit.inventory.Inventory
 - 
getHolder
@Nullable public @Nullable org.bukkit.inventory.InventoryHolder getHolder(boolean snapshotBlockEntity) - Specified by:
 getHolderin interfaceorg.bukkit.inventory.Inventory
 - 
iterator
 - 
iterator
- Specified by:
 iteratorin interfaceorg.bukkit.inventory.Inventory
 - 
getLocation
public org.bukkit.Location getLocation()- Specified by:
 getLocationin interfaceorg.bukkit.inventory.Inventory
 - 
getItem
@NotNull public @NotNull org.bukkit.inventory.ItemStack getItem(int index) - Specified by:
 getItemin interfaceorg.bukkit.inventory.Inventory
 - 
setItem
public void setItem(int index, org.bukkit.inventory.ItemStack item) - Specified by:
 setItemin interfaceorg.bukkit.inventory.Inventory
 - 
addItem
@NotNull public @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack> addItem(org.bukkit.inventory.ItemStack... items) - Specified by:
 addItemin interfaceorg.bukkit.inventory.Inventory
 - 
addItemStack
public org.bukkit.inventory.ItemStack addItemStack(org.bukkit.inventory.ItemStack item, boolean ignoreMeta) Adds the contents of the given ItemStack to the inventory.- Parameters:
 item- the ItemStack to addignoreMeta- if true, can convert to items with different NBT data in order to stack with existing copies of those items, provided the material and damage value match- Returns:
 - the items that couldn't be added, or an empty stack if all were added
 
 - 
removeItem
@NotNull public @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack> removeItem(org.bukkit.inventory.ItemStack... items) - Specified by:
 removeItemin interfaceorg.bukkit.inventory.Inventory
 - 
removeItemStack
public org.bukkit.inventory.ItemStack removeItemStack(org.bukkit.inventory.ItemStack item, boolean ignoreMeta) Removes the given ItemStack from the inventory.- Parameters:
 item- the ItemStack to removeignoreMeta- if true, can choose an item with different NBT data, provided the material and damage value match- Returns:
 - the items that couldn't be removed, or an empty stack if all were removed
 
 - 
getContents
public org.bukkit.inventory.ItemStack @NotNull [] getContents()- Specified by:
 getContentsin interfaceorg.bukkit.inventory.Inventory
 - 
setContents
public void setContents(org.bukkit.inventory.ItemStack[] items) - Specified by:
 setContentsin interfaceorg.bukkit.inventory.Inventory
 - 
getStorageContents
public org.bukkit.inventory.ItemStack[] getStorageContents()- Specified by:
 getStorageContentsin interfaceorg.bukkit.inventory.Inventory
 - 
setStorageContents
public void setStorageContents(org.bukkit.inventory.ItemStack[] items) throws IllegalArgumentException - Specified by:
 setStorageContentsin interfaceorg.bukkit.inventory.Inventory- Throws:
 IllegalArgumentException
 - 
toString
 - 
contains
public boolean contains(@NotNull @NotNull org.bukkit.Material material) - Specified by:
 containsin interfaceorg.bukkit.inventory.Inventory
 - 
contains
public boolean contains(org.bukkit.inventory.ItemStack item) - Specified by:
 containsin interfaceorg.bukkit.inventory.Inventory
 - 
contains
public boolean contains(@NotNull @NotNull org.bukkit.Material material, int amount) - Specified by:
 containsin interfaceorg.bukkit.inventory.Inventory
 - 
contains
public boolean contains(org.bukkit.inventory.ItemStack item, int amount) - Specified by:
 containsin interfaceorg.bukkit.inventory.Inventory
 - 
containsAtLeast
public boolean containsAtLeast(org.bukkit.inventory.ItemStack item, int amount) - Specified by:
 containsAtLeastin interfaceorg.bukkit.inventory.Inventory
 - 
all
@NotNull public @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack> all(@NotNull @NotNull org.bukkit.Material material) - Specified by:
 allin interfaceorg.bukkit.inventory.Inventory
 - 
all
@NotNull public @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack> all(org.bukkit.inventory.ItemStack item) - Specified by:
 allin interfaceorg.bukkit.inventory.Inventory
 - 
first
public int first(@NotNull @NotNull org.bukkit.Material material) - Specified by:
 firstin interfaceorg.bukkit.inventory.Inventory
 - 
first
public int first(@NotNull @NotNull org.bukkit.inventory.ItemStack item) - Specified by:
 firstin interfaceorg.bukkit.inventory.Inventory
 - 
firstEmpty
public int firstEmpty()- Specified by:
 firstEmptyin interfaceorg.bukkit.inventory.Inventory
 - 
isEmpty
public boolean isEmpty()- Specified by:
 isEmptyin interfaceorg.bukkit.inventory.Inventory
 - 
remove
public void remove(@NotNull @NotNull org.bukkit.Material material) - Specified by:
 removein interfaceorg.bukkit.inventory.Inventory
 - 
remove
public void remove(@NotNull @NotNull org.bukkit.inventory.ItemStack item) - Specified by:
 removein interfaceorg.bukkit.inventory.Inventory
 - 
clear
public void clear(int index) - Specified by:
 clearin interfaceorg.bukkit.inventory.Inventory
 - 
clear
public void clear()- Specified by:
 clearin interfaceorg.bukkit.inventory.Inventory
 - 
close
public int close()- Specified by:
 closein interfaceorg.bukkit.inventory.Inventory
 - 
consumeItem
public int consumeItem(int slot, boolean wholeStack) Consumes an item or the full stack in the given slot.- Parameters:
 slot- The slot to consume.wholeStack- True if we should remove the complete stack.- Returns:
 - The number of item really consumed.
 
 - 
consumeItem
public int consumeItem(int slot) Consumes an item in the given slot.- Parameters:
 slot- The slot to consume.- Returns:
 - The number of item really consumed.
 
 - 
getHolder
public org.bukkit.inventory.InventoryHolder getHolder()The owner of this inventory.- Specified by:
 getHolderin interfaceorg.bukkit.inventory.Inventory
 - 
getType
public org.bukkit.event.inventory.InventoryType getType()The type of this inventory.- Specified by:
 getTypein interfaceorg.bukkit.inventory.Inventory
 - 
getTitle
The inventory's name. - 
getMaxStackSize
public int getMaxStackSize()The inventory's maximum stack size.- Specified by:
 getMaxStackSizein interfaceorg.bukkit.inventory.Inventory
 - 
setMaxStackSize
public void setMaxStackSize(int maxStackSize) The inventory's maximum stack size.- Specified by:
 setMaxStackSizein interfaceorg.bukkit.inventory.Inventory
 
 -