Package dev.aurelium.slate.inv.content
Class InventoryContents.Impl
java.lang.Object
dev.aurelium.slate.inv.content.InventoryContents.Impl
- All Implemented Interfaces:
InventoryContents
- Enclosing interface:
- InventoryContents
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.aurelium.slate.inv.content.InventoryContents
InventoryContents.Impl -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(ClickableItem item) Adds an item to the first empty slot of the inventory.ClickableItem[][]all()Returns a 2D array of ClickableItems containing all the items of the inventory.applyRect(int fromRow, int fromColumn, int toRow, int toColumn, BiConsumer<Integer, Integer> apply) Apply the consumer on a rectangle inside the inventory using the given positions.applyRect(int fromRow, int fromColumn, int toRow, int toColumn, Consumer<ClickableItem> apply) Apply the consumer on a rectangle inside the inventory using the given positions.fill(ClickableItem item) Fills the inventory with the given item.fillBorders(ClickableItem item) Fills the inventory borders with the given item.fillColumn(int column, ClickableItem item) Fills the given inventory column with the given item.fillPattern(Pattern<ClickableItem> pattern) Fills the inventory with the givenPattern.fillPattern(Pattern<ClickableItem> pattern, int startIndex) Fills the inventory with the givenPattern.fillPattern(Pattern<ClickableItem> pattern, int startRow, int startColumn) Fills the inventory with the givenPattern.fillPattern(Pattern<ClickableItem> pattern, SlotPos startPos) Fills the inventory with the givenPattern.fillPatternRepeating(Pattern<ClickableItem> pattern) Fills the inventory with the givenPattern.fillPatternRepeating(Pattern<ClickableItem> pattern, int startIndex, int endIndex) Fills the inventory with the givenPattern.fillPatternRepeating(Pattern<ClickableItem> pattern, int startRow, int startColumn, int endRow, int endColumn) Fills the inventory with the givenPattern.fillPatternRepeating(Pattern<ClickableItem> pattern, SlotPos startPos, SlotPos endPos) Fills the inventory with the givenPattern.fillRect(int fromRow, int fromColumn, int toRow, int toColumn, ClickableItem item) Same asInventoryContents.fillRect(int, int, ClickableItem), but withSlotPosinstead of the indexes.fillRect(int fromIndex, int toIndex, ClickableItem item) Fills a rectangle inside the inventory using the given positions.fillRect(SlotPos fromPos, SlotPos toPos, ClickableItem item) Same asInventoryContents.fillRect(int, int, ClickableItem), but with rows and columns instead of the indexes.fillRow(int row, ClickableItem item) Fills the given inventory row with the given item.fillSquare(int fromRow, int fromColumn, int toRow, int toColumn, ClickableItem item) Completely fills the provided square with the givenClickableItem.fillSquare(int fromIndex, int toIndex, ClickableItem item) Completely fills the provided square with the givenClickableItem.fillSquare(SlotPos fromPos, SlotPos toPos, ClickableItem item) Completely fills the provided square with the givenClickableItem.findItem(ClickableItem clickableItem) Looks for the given item and compares them usingItemStack.isSimilar(ItemStack), ignoring the amount.findItem(org.bukkit.inventory.ItemStack itemStack) Looks for the given item and compares them usingItemStack.isSimilar(ItemStack), ignoring the amount.Returns the position of the first empty slot in the inventory, orOptional.empty()if there is no free slot.get(int index) Returns the item in the inventory at the given slot index, orOptional.empty()if the slot is empty or if the index is out of bounds.get(int row, int column) Same asInventoryContents.get(int), but with a row and a column instead of the index.Same asInventoryContents.get(int), but with aSlotPosinstead of the index.Gets the inventory linked to thisInventoryContents.booleanisEditable(SlotPos slot) Returns if a given slot is editable or not.Gets a previously registered iterator named with the given id.newIterator(SlotIterator.Type type, int startRow, int startColumn) Creates and returns an iterator.newIterator(SlotIterator.Type type, SlotPos startPos) newIterator(String id, SlotIterator.Type type, int startRow, int startColumn) Creates and registers an iterator using a given id.newIterator(String id, SlotIterator.Type type, SlotPos startPos) Gets the pagination system linked to thisInventoryContents.<T> TGets the value of the property with the given name.<T> TGets the value of the property with the given name, or a default value if the property isn't set.set(int row, int column, ClickableItem item) Same asInventoryContents.set(int, ClickableItem), but with a row and a column instead of the index.set(int index, ClickableItem item) Sets the item in the inventory at the given slot index.set(SlotPos slotPos, ClickableItem item) Same asInventoryContents.set(int, ClickableItem), but with aSlotPosinstead of the index.voidsetEditable(SlotPos slot, boolean editable) Makes a slot editable, which enables the player to put items in and take items out of the inventory in the specified slot.setProperty(String name, Object value) Sets the value of the property with the given name.slots()Returns a list of all the slots in the inventory.updateItem(int row, int column, org.bukkit.inventory.ItemStack itemStack) Same asInventoryContents.updateItem(int, ItemStack), but with a row and a column instead of the index.updateItem(int index, org.bukkit.inventory.ItemStack itemStack) Updates theItemStackof the givenClickableItemat the given slot in this inventory.updateItem(SlotPos slotPos, org.bukkit.inventory.ItemStack itemStack) Same asInventoryContents.updateItem(int, ItemStack), but with aSlotPosinstead of the index.
-
Constructor Details
-
Impl
-
-
Method Details
-
inventory
Description copied from interface:InventoryContents- Specified by:
inventoryin interfaceInventoryContents- Returns:
- the inventory
-
pagination
Description copied from interface:InventoryContents- Specified by:
paginationin interfaceInventoryContents- Returns:
- the pagination
-
iterator
Description copied from interface:InventoryContentsGets a previously registered iterator named with the given id.
If no iterator is found, this will returnOptional.empty().- Specified by:
iteratorin interfaceInventoryContents- Parameters:
id- the id of the iterator- Returns:
- the found iterator, if there is one
-
newIterator
Description copied from interface:InventoryContentsCreates and registers an iterator using a given id.You can retrieve the iterator at any time using the
InventoryContents.iterator(String)method.- Specified by:
newIteratorin interfaceInventoryContents- Parameters:
id- the id of the iteratortype- the type of the iteratorstartRow- the starting row of the iteratorstartColumn- the starting column of the iterator- Returns:
- the newly created iterator
-
newIterator
- Specified by:
newIteratorin interfaceInventoryContents
-
newIterator
Description copied from interface:InventoryContentsCreates and returns an iterator.This does NOT registers the iterator, thus
InventoryContents.iterator(String)will not be able to return the iterators created with this method.- Specified by:
newIteratorin interfaceInventoryContents- Parameters:
type- the type of the iteratorstartRow- the starting row of the iteratorstartColumn- the starting column of the iterator- Returns:
- the newly created iterator
-
newIterator
- Specified by:
newIteratorin interfaceInventoryContents
-
all
Description copied from interface:InventoryContentsReturns a 2D array of ClickableItems containing all the items of the inventory. The ClickableItems can be null when there is no item in the corresponding slot.- Specified by:
allin interfaceInventoryContents- Returns:
- the items of the inventory
-
slots
Description copied from interface:InventoryContentsReturns a list of all the slots in the inventory.- Specified by:
slotsin interfaceInventoryContents- Returns:
- the inventory slots
-
firstEmpty
Description copied from interface:InventoryContentsReturns the position of the first empty slot in the inventory, orOptional.empty()if there is no free slot.- Specified by:
firstEmptyin interfaceInventoryContents- Returns:
- the first empty slot, if there is one
-
get
Description copied from interface:InventoryContentsReturns the item in the inventory at the given slot index, orOptional.empty()if the slot is empty or if the index is out of bounds.- Specified by:
getin interfaceInventoryContents- Parameters:
index- the slot index- Returns:
- the found item, if there is one
-
get
Description copied from interface:InventoryContentsSame asInventoryContents.get(int), but with a row and a column instead of the index.- Specified by:
getin interfaceInventoryContents- See Also:
-
get
Description copied from interface:InventoryContentsSame asInventoryContents.get(int), but with aSlotPosinstead of the index.- Specified by:
getin interfaceInventoryContents- See Also:
-
applyRect
public InventoryContents applyRect(int fromRow, int fromColumn, int toRow, int toColumn, BiConsumer<Integer, Integer> apply) Description copied from interface:InventoryContentsApply the consumer on a rectangle inside the inventory using the given positions.
The created rectangle will have its top-left position at the given from slot index and its bottom-right position at the given to slot index.- Specified by:
applyRectin interfaceInventoryContentsapply- BiConsumer to accept row and column- Returns:
this, for chained calls
-
applyRect
public InventoryContents applyRect(int fromRow, int fromColumn, int toRow, int toColumn, Consumer<ClickableItem> apply) Description copied from interface:InventoryContentsApply the consumer on a rectangle inside the inventory using the given positions. Applies only when the ClickableItem exist in this GUI.
The created rectangle will have its top-left position at the given from slot index and its bottom-right position at the given to slot index.- Specified by:
applyRectin interfaceInventoryContentsapply- Consumer to accept each slot- Returns:
this, for chained calls
-
set
Description copied from interface:InventoryContentsSets the item in the inventory at the given slot index.- Specified by:
setin interfaceInventoryContents- Parameters:
index- the slot indexitem- the item to set, ornullto clear the slot- Returns:
this, for chained calls
-
set
Description copied from interface:InventoryContentsSame asInventoryContents.set(int, ClickableItem), but with a row and a column instead of the index.- Specified by:
setin interfaceInventoryContents- See Also:
-
set
Description copied from interface:InventoryContentsSame asInventoryContents.set(int, ClickableItem), but with aSlotPosinstead of the index.- Specified by:
setin interfaceInventoryContents- See Also:
-
add
Description copied from interface:InventoryContentsAdds an item to the first empty slot of the inventory.
Warning: If there is already a stack of the same item, this will not add the item to the stack, this will always add the item into an empty slot.- Specified by:
addin interfaceInventoryContents- Parameters:
item- the item to add- Returns:
this, for chained calls
-
updateItem
Description copied from interface:InventoryContentsUpdates theItemStackof the givenClickableItemat the given slot in this inventory.
If there's noClickableItemat the given slot, it creates an emptyClickableItemwith the givenItemStack.- Specified by:
updateItemin interfaceInventoryContents- Parameters:
index- the slot index of the item to updateitemStack- the newItemStack- Returns:
this, for chained calls
-
updateItem
Description copied from interface:InventoryContentsSame asInventoryContents.updateItem(int, ItemStack), but with a row and a column instead of the index.- Specified by:
updateItemin interfaceInventoryContents- See Also:
-
updateItem
Description copied from interface:InventoryContentsSame asInventoryContents.updateItem(int, ItemStack), but with aSlotPosinstead of the index.- Specified by:
updateItemin interfaceInventoryContents- See Also:
-
findItem
Description copied from interface:InventoryContentsLooks for the given item and compares them usingItemStack.isSimilar(ItemStack), ignoring the amount.
This method searches row for row from left to right.- Specified by:
findItemin interfaceInventoryContents- Parameters:
itemStack- the item to look for- Returns:
- an optional containing the position where the item first occurred, or an empty optional
-
findItem
Description copied from interface:InventoryContentsLooks for the given item and compares them usingItemStack.isSimilar(ItemStack), ignoring the amount.
This method searches row for row from left to right.- Specified by:
findItemin interfaceInventoryContents- Parameters:
clickableItem- the clickable item with the item stack to look for- Returns:
- an optional containing the position where the item first occurred, or an empty optional
-
fill
Description copied from interface:InventoryContentsFills the inventory with the given item.- Specified by:
fillin interfaceInventoryContents- Parameters:
item- the item- Returns:
this, for chained calls
-
fillRow
Description copied from interface:InventoryContentsFills the given inventory row with the given item.- Specified by:
fillRowin interfaceInventoryContents- Parameters:
row- the row to fillitem- the item- Returns:
this, for chained calls
-
fillColumn
Description copied from interface:InventoryContentsFills the given inventory column with the given item.- Specified by:
fillColumnin interfaceInventoryContents- Parameters:
column- the column to fillitem- the item- Returns:
this, for chained calls
-
fillBorders
Description copied from interface:InventoryContentsFills the inventory borders with the given item.- Specified by:
fillBordersin interfaceInventoryContents- Parameters:
item- the item- Returns:
this, for chained calls
-
fillRect
Description copied from interface:InventoryContentsFills a rectangle inside the inventory using the given positions.
The created rectangle will have its top-left position at the given from slot index and its bottom-right position at the given to slot index.- Specified by:
fillRectin interfaceInventoryContents- Parameters:
fromIndex- the slot index at the top-left positiontoIndex- the slot index at the bottom-right positionitem- the item- Returns:
this, for chained calls
-
fillRect
public InventoryContents fillRect(int fromRow, int fromColumn, int toRow, int toColumn, ClickableItem item) Description copied from interface:InventoryContentsSame asInventoryContents.fillRect(int, int, ClickableItem), but withSlotPosinstead of the indexes.- Specified by:
fillRectin interfaceInventoryContents- See Also:
-
fillRect
Description copied from interface:InventoryContentsSame asInventoryContents.fillRect(int, int, ClickableItem), but with rows and columns instead of the indexes.- Specified by:
fillRectin interfaceInventoryContents- See Also:
-
fillSquare
Description copied from interface:InventoryContentsCompletely fills the provided square with the givenClickableItem.- Specified by:
fillSquarein interfaceInventoryContents- Parameters:
fromIndex- the slot index of the upper left cornertoIndex- the slot index of the lower right corneritem- the item- Returns:
this, for chained calls
-
fillSquare
public InventoryContents fillSquare(int fromRow, int fromColumn, int toRow, int toColumn, ClickableItem item) Description copied from interface:InventoryContentsCompletely fills the provided square with the givenClickableItem.- Specified by:
fillSquarein interfaceInventoryContents- Parameters:
fromRow- the row of the upper left cornerfromColumn- the column of the upper-left cornertoRow- the row of the lower right cornertoColumn- the column of the lower right corneritem- the item- Returns:
this, for chained calls
-
fillSquare
Description copied from interface:InventoryContentsCompletely fills the provided square with the givenClickableItem.- Specified by:
fillSquarein interfaceInventoryContents- Parameters:
fromPos- the slot position of the upper left cornertoPos- the slot position of the lower right corneritem- the item- Returns:
this, for chained calls
-
fillPattern
Description copied from interface:InventoryContentsFills the inventory with the givenPattern.
The pattern will start at the first slot.- Specified by:
fillPatternin interfaceInventoryContents- Parameters:
pattern- the filling pattern- Returns:
this, for chained calls- See Also:
-
fillPattern
Description copied from interface:InventoryContentsFills the inventory with the givenPattern.
The pattern will start at the given slot index.- Specified by:
fillPatternin interfaceInventoryContents- Parameters:
pattern- the filling patternstartIndex- the start slot index for the filling- Returns:
this, for chained calls- See Also:
-
fillPattern
Description copied from interface:InventoryContentsFills the inventory with the givenPattern.
The pattern will start at the given slot position.- Specified by:
fillPatternin interfaceInventoryContents- Parameters:
pattern- the filling patternstartPos- the start position of the slot for filling- Returns:
this, for chained calls- See Also:
-
fillPatternRepeating
Description copied from interface:InventoryContentsFills the inventory with the givenPattern.
The pattern will start at the first slot and end at the last slot. If the pattern is not big enough, it will wrap around to the other side and repeat the pattern.
The top-left corner of the specified inventory area is also the top-left corner of the specified pattern.
For this to work the pattern needs to be created withwrapAroundenabled.- Specified by:
fillPatternRepeatingin interfaceInventoryContents- Parameters:
pattern- the filling pattern- Returns:
this, for chained calls- See Also:
-
fillPatternRepeating
public InventoryContents fillPatternRepeating(Pattern<ClickableItem> pattern, int startIndex, int endIndex) Description copied from interface:InventoryContentsFills the inventory with the givenPattern.
The pattern will start at the first slot index and end at the second slot index. If the pattern is not big enough, it will wrap around to the other side and repeat the pattern.
The top-left corner of the specified inventory area is also the top-left corner of the specified pattern.
IfendIndexis a negative value it is set to the bottom-right corner.
For this to work the pattern needs to be created withwrapAroundenabled.- Specified by:
fillPatternRepeatingin interfaceInventoryContents- Parameters:
pattern- the filling patternstartIndex- the start slot index where the pattern should beginendIndex- the end slot index where the pattern should end- Returns:
this, for chained calls- See Also:
-
fillPatternRepeating
public InventoryContents fillPatternRepeating(Pattern<ClickableItem> pattern, int startRow, int startColumn, int endRow, int endColumn) Description copied from interface:InventoryContentsFills the inventory with the givenPattern.
The pattern will start at the given slot position and end at the second slot position. If the pattern is not big enough, it will wrap around to the other side and repeat the pattern.
The top-left corner of the specified inventory area is also the top-left corner of the specified pattern.
IfendRowis a negative value, endRow is automatically set to the max row size, ifendColumnis a negative value, endColumn is automatically set to the max column size.
For this to work the pattern needs to be created withwrapAroundenabled.- Specified by:
fillPatternRepeatingin interfaceInventoryContents- Parameters:
pattern- the filling patternstartRow- the start row of the slot for fillingstartColumn- the start column of the slot for fillingendRow- the end row of the slot for fillingendColumn- the end column of the slot for filling- Returns:
this, for chained calls- See Also:
-
fillPatternRepeating
public InventoryContents fillPatternRepeating(Pattern<ClickableItem> pattern, SlotPos startPos, SlotPos endPos) Description copied from interface:InventoryContentsFills the inventory with the givenPattern.
The pattern will start at the given slot position and end at the second slot position. If the pattern is not big enough, it will wrap around to the other side and repeat the pattern.
The top-left corner of the specified inventory area is also the top-left corner of the specified pattern.
If the row ofendPosis a negative value, endRow is automatically set to the max row size, if the column ofendPosis a negative value, endColumn is automatically set to the max column size.
For this to work the pattern needs to be created withwrapAroundenabled.- Specified by:
fillPatternRepeatingin interfaceInventoryContents- Parameters:
pattern- the filling patternstartPos- the position where the pattern should startendPos- the position where the pattern should end- Returns:
this, for chained calls- See Also:
-
fillPattern
Description copied from interface:InventoryContentsFills the inventory with the givenPattern.
The pattern will start at the given slot position based on the provided row and column.- Specified by:
fillPatternin interfaceInventoryContents- Parameters:
pattern- the filling patternstartRow- the start row of the slot for fillingstartColumn- the start column of the slot for filling- Returns:
this, for chained calls- See Also:
-
property
Description copied from interface:InventoryContentsGets the value of the property with the given name.- Specified by:
propertyin interfaceInventoryContents- Type Parameters:
T- the type of the value- Parameters:
name- the property's name- Returns:
- the property's value
-
property
Description copied from interface:InventoryContentsGets the value of the property with the given name, or a default value if the property isn't set.- Specified by:
propertyin interfaceInventoryContents- Type Parameters:
T- the type of the value- Parameters:
name- the property's namedef- the default value- Returns:
- the property's value, or the given default value
-
setProperty
Description copied from interface:InventoryContentsSets the value of the property with the given name.
This will replace the existing value for the property, if there is one.- Specified by:
setPropertyin interfaceInventoryContents- Parameters:
name- the property's namevalue- the new property's value- Returns:
this, for chained calls
-
setEditable
Description copied from interface:InventoryContentsMakes a slot editable, which enables the player to put items in and take items out of the inventory in the specified slot.- Specified by:
setEditablein interfaceInventoryContents- Parameters:
slot- The slot to set editableeditable-trueto make a slot editable,falseto make it 'static' again.
-
isEditable
Description copied from interface:InventoryContentsReturns if a given slot is editable or not.- Specified by:
isEditablein interfaceInventoryContents- Parameters:
slot- The slot to check- Returns:
trueif the editable.- See Also:
-