public class GlowInventory extends Object implements org.bukkit.inventory.Inventory
| Modifier | Constructor and Description |
|---|---|
protected |
GlowInventory() |
|
GlowInventory(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) |
| Modifier and Type | Method and Description |
|---|---|
HashMap<Integer,org.bukkit.inventory.ItemStack> |
addItem(org.bukkit.inventory.ItemStack... items) |
org.bukkit.inventory.ItemStack |
addItemStack(org.bukkit.inventory.ItemStack item,
boolean ignoreMeta)
Adds the contents of the given ItemStack to the inventory.
|
void |
addViewer(org.bukkit.entity.HumanEntity viewer)
Add a viewer to the inventory.
|
HashMap<Integer,org.bukkit.inventory.ItemStack> |
all(int materialId) |
HashMap<Integer,org.bukkit.inventory.ItemStack> |
all(org.bukkit.inventory.ItemStack item) |
HashMap<Integer,org.bukkit.inventory.ItemStack> |
all(org.bukkit.Material material) |
void |
clear() |
void |
clear(int index) |
int |
consumeItem(int slot)
Consumes an item in the given slot.
|
int |
consumeItem(int slot,
boolean wholeStack)
Consumes an item or the full stack in the given slot.
|
boolean |
contains(int materialId) |
boolean |
contains(int materialId,
int amount) |
boolean |
contains(org.bukkit.inventory.ItemStack item) |
boolean |
contains(org.bukkit.inventory.ItemStack item,
int amount) |
boolean |
contains(org.bukkit.Material material) |
boolean |
contains(org.bukkit.Material material,
int amount) |
boolean |
containsAtLeast(org.bukkit.inventory.ItemStack item,
int amount) |
int |
first(int materialId) |
int |
first(org.bukkit.inventory.ItemStack item) |
int |
first(org.bukkit.Material material) |
int |
firstEmpty() |
org.bukkit.inventory.ItemStack[] |
getContents() |
org.bukkit.inventory.InventoryHolder |
getHolder()
The owner of this inventory.
|
org.bukkit.inventory.ItemStack |
getItem(int index) |
org.bukkit.Location |
getLocation() |
int |
getMaxStackSize()
The inventory's maximum stack size.
|
String |
getName() |
int |
getRawSlots()
Gets the number of slots in this inventory according to the protocol.
|
int |
getSize() |
GlowInventorySlot |
getSlot(int slot)
Returns a certain slot.
|
List<GlowInventorySlot> |
getSlots()
Returns the whole slot list.
|
org.bukkit.event.inventory.InventoryType.SlotType |
getSlotType(int slot)
Get the type of the specified slot.
|
org.bukkit.inventory.ItemStack[] |
getStorageContents() |
String |
getTitle()
The inventory's name.
|
org.bukkit.event.inventory.InventoryType |
getType()
The type of this inventory.
|
List<org.bukkit.entity.HumanEntity> |
getViewers() |
Set<org.bukkit.entity.HumanEntity> |
getViewersSet()
Returns the set which contains viewers.
|
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.
|
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.
|
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.
|
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.
|
ListIterator<org.bukkit.inventory.ItemStack> |
iterator() |
ListIterator<org.bukkit.inventory.ItemStack> |
iterator(int index) |
void |
remove(int materialId) |
void |
remove(org.bukkit.inventory.ItemStack item) |
void |
remove(org.bukkit.Material material) |
HashMap<Integer,org.bukkit.inventory.ItemStack> |
removeItem(org.bukkit.inventory.ItemStack... items) |
org.bukkit.inventory.ItemStack |
removeItemStack(org.bukkit.inventory.ItemStack item,
boolean ignoreMeta)
Removes the given ItemStack from the inventory.
|
void |
removeViewer(org.bukkit.entity.HumanEntity viewer)
Remove a viewer from the inventory.
|
void |
setContents(org.bukkit.inventory.ItemStack[] items) |
void |
setItem(int index,
org.bukkit.inventory.ItemStack item) |
void |
setMaxStackSize(int maxStackSize)
The inventory's maximum stack size.
|
void |
setStorageContents(org.bukkit.inventory.ItemStack[] items) |
void |
setTitle(String title)
Set the custom title of this inventory or reset it to the default.
|
String |
toString() |
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).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorprotected GlowInventory()
public GlowInventory(org.bukkit.inventory.InventoryHolder holder,
org.bukkit.event.inventory.InventoryType type)
public GlowInventory(org.bukkit.inventory.InventoryHolder holder,
org.bukkit.event.inventory.InventoryType type,
int size)
public GlowInventory(org.bukkit.inventory.InventoryHolder holder,
org.bukkit.event.inventory.InventoryType type,
int size,
String title)
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)
This should be called in the constructor.
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.public void addViewer(org.bukkit.entity.HumanEntity viewer)
viewer - The HumanEntity to add.public void removeViewer(org.bukkit.entity.HumanEntity viewer)
viewer - The HumanEntity to remove.public Set<org.bukkit.entity.HumanEntity> getViewersSet()
public GlowInventorySlot getSlot(int slot)
slot - index.public org.bukkit.event.inventory.InventoryType.SlotType getSlotType(int slot)
slot - The slot number.public boolean itemPlaceAllowed(int slot,
org.bukkit.inventory.ItemStack stack)
Should return false for crafting output slots or armor slots which cannot accept the given item.
slot - The slot number.stack - The stack to add.public boolean itemShiftClickAllowed(int slot,
org.bukkit.inventory.ItemStack stack)
slot - The slot number.stack - The stack to add.public void handleShiftClick(GlowPlayer player, org.bukkit.inventory.InventoryView view, int clickedSlot, org.bukkit.inventory.ItemStack clickedItem)
The default implementation distributes items from the right to the left and from the bottom to the top.
player - The player who clickedview - The inventory view in which was clickedclickedSlot - The slot in the viewclickedItem - The item at which was clickedpublic org.bukkit.inventory.ItemStack tryToFillSlots(org.bukkit.inventory.ItemStack stack,
int... slots)
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.
stack - The items to place downslots - Pairs of start/end slotsnull if non are remainingpublic int getRawSlots()
Some inventories have 0 slots in the protocol, despite having slots.
public int getSize()
getSize in interface org.bukkit.inventory.Inventorypublic List<GlowInventorySlot> getSlots()
public final String getName()
getName in interface org.bukkit.inventory.Inventorypublic void setTitle(String title)
title - The new title, or null to reset.public List<org.bukkit.entity.HumanEntity> getViewers()
getViewers in interface org.bukkit.inventory.Inventorypublic ListIterator<org.bukkit.inventory.ItemStack> iterator()
public ListIterator<org.bukkit.inventory.ItemStack> iterator(int index)
iterator in interface org.bukkit.inventory.Inventorypublic org.bukkit.Location getLocation()
getLocation in interface org.bukkit.inventory.Inventorypublic org.bukkit.inventory.ItemStack getItem(int index)
getItem in interface org.bukkit.inventory.Inventorypublic void setItem(int index,
org.bukkit.inventory.ItemStack item)
setItem in interface org.bukkit.inventory.Inventorypublic HashMap<Integer,org.bukkit.inventory.ItemStack> addItem(org.bukkit.inventory.ItemStack... items)
addItem in interface org.bukkit.inventory.Inventorypublic org.bukkit.inventory.ItemStack addItemStack(org.bukkit.inventory.ItemStack item,
boolean ignoreMeta)
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 matchpublic HashMap<Integer,org.bukkit.inventory.ItemStack> removeItem(org.bukkit.inventory.ItemStack... items)
removeItem in interface org.bukkit.inventory.Inventorypublic org.bukkit.inventory.ItemStack removeItemStack(org.bukkit.inventory.ItemStack item,
boolean ignoreMeta)
item - the ItemStack to removeignoreMeta - if true, can choose an item with different NBT data, provided the material
and damage value matchpublic org.bukkit.inventory.ItemStack[] getContents()
getContents in interface org.bukkit.inventory.Inventorypublic void setContents(org.bukkit.inventory.ItemStack[] items)
setContents in interface org.bukkit.inventory.Inventorypublic org.bukkit.inventory.ItemStack[] getStorageContents()
getStorageContents in interface org.bukkit.inventory.Inventorypublic void setStorageContents(org.bukkit.inventory.ItemStack[] items)
throws IllegalArgumentException
setStorageContents in interface org.bukkit.inventory.InventoryIllegalArgumentExceptionpublic boolean contains(int materialId)
contains in interface org.bukkit.inventory.Inventorypublic boolean contains(org.bukkit.Material material)
contains in interface org.bukkit.inventory.Inventorypublic boolean contains(org.bukkit.inventory.ItemStack item)
contains in interface org.bukkit.inventory.Inventorypublic boolean contains(int materialId,
int amount)
contains in interface org.bukkit.inventory.Inventorypublic boolean contains(org.bukkit.Material material,
int amount)
contains in interface org.bukkit.inventory.Inventorypublic boolean contains(org.bukkit.inventory.ItemStack item,
int amount)
contains in interface org.bukkit.inventory.Inventorypublic boolean containsAtLeast(org.bukkit.inventory.ItemStack item,
int amount)
containsAtLeast in interface org.bukkit.inventory.Inventorypublic HashMap<Integer,org.bukkit.inventory.ItemStack> all(int materialId)
all in interface org.bukkit.inventory.Inventorypublic HashMap<Integer,org.bukkit.inventory.ItemStack> all(org.bukkit.Material material)
all in interface org.bukkit.inventory.Inventorypublic HashMap<Integer,org.bukkit.inventory.ItemStack> all(org.bukkit.inventory.ItemStack item)
all in interface org.bukkit.inventory.Inventorypublic int first(int materialId)
first in interface org.bukkit.inventory.Inventorypublic int first(org.bukkit.Material material)
first in interface org.bukkit.inventory.Inventorypublic int first(org.bukkit.inventory.ItemStack item)
first in interface org.bukkit.inventory.Inventorypublic int firstEmpty()
firstEmpty in interface org.bukkit.inventory.Inventorypublic void remove(int materialId)
remove in interface org.bukkit.inventory.Inventorypublic void remove(org.bukkit.Material material)
remove in interface org.bukkit.inventory.Inventorypublic void remove(org.bukkit.inventory.ItemStack item)
remove in interface org.bukkit.inventory.Inventorypublic void clear(int index)
clear in interface org.bukkit.inventory.Inventorypublic void clear()
clear in interface org.bukkit.inventory.Inventorypublic int consumeItem(int slot,
boolean wholeStack)
slot - The slot to consume.wholeStack - True if we should remove the complete stack.public int consumeItem(int slot)
slot - The slot to consume.public org.bukkit.inventory.InventoryHolder getHolder()
getHolder in interface org.bukkit.inventory.Inventorypublic org.bukkit.event.inventory.InventoryType getType()
getType in interface org.bukkit.inventory.Inventorypublic String getTitle()
getTitle in interface org.bukkit.inventory.Inventorypublic int getMaxStackSize()
getMaxStackSize in interface org.bukkit.inventory.Inventorypublic void setMaxStackSize(int maxStackSize)
setMaxStackSize in interface org.bukkit.inventory.InventoryCopyright © 2021. All rights reserved.