public interface InventoryContents
this contains several methods which let you get and modify the content of the inventory.
for example, you can get the item at a given slot by
using get(SlotPos). You can
also fill an entire column with the use of the method
fillColumn(int, Icon).
| Modifier and Type | Method and Description |
|---|---|
default @NotNull InventoryContents |
add(@NotNull Icon item)
adds an item to the first empty slot of the inventory.
|
@NotNull Icon[][] |
all()
returns a 2D array of
Icon containing
all the items of the inventory. |
default @NotNull InventoryContents |
applyRect(int fromRow,
int fromColumn,
int toRow,
int toColumn,
@NotNull Consumer<Icon> apply)
applies the consumer on a rectangle inside the inventory using the given
positions.
|
default @NotNull InventoryContents |
applyRect(int fromRow,
int fromColumn,
int toRow,
int toColumn,
@NotNull ObjIntConsumer<Integer> apply)
applie the consumer on a rectangle inside the inventory using the given
positions.
|
default @NotNull InventoryContents |
fill(@NotNull Icon item)
fills the inventory with the given item.
|
default @NotNull InventoryContents |
fillBorders(@NotNull Icon item)
fills the inventory borders with the given item.
|
default @NotNull InventoryContents |
fillColumn(int column,
@NotNull Icon item)
fills the given inventory column with the given item.
|
default @NotNull InventoryContents |
fillEmpties(@NotNull Icon item)
fills the empty slots of the inventory with the given item.
|
default @NotNull InventoryContents |
fillPattern(@NotNull Pattern<Icon> pattern)
fills the inventory with the given
Pattern. |
default @NotNull InventoryContents |
fillPattern(@NotNull Pattern<Icon> pattern,
int startIndex)
fills the inventory with the given
Pattern. |
default @NotNull InventoryContents |
fillPattern(@NotNull Pattern<Icon> pattern,
int startRow,
int startColumn)
fills the inventory with the given
Pattern. |
default @NotNull InventoryContents |
fillPattern(@NotNull Pattern<Icon> pattern,
@NotNull SlotPos startPos)
fills the inventory with the given
Pattern. |
default @NotNull InventoryContents |
fillPatternRepeating(@NotNull Pattern<Icon> pattern)
fills the inventory with the given
Pattern. |
default @NotNull InventoryContents |
fillPatternRepeating(@NotNull Pattern<Icon> pattern,
int startIndex,
int endIndex)
fills the inventory with the given
Pattern. |
default @NotNull InventoryContents |
fillPatternRepeating(@NotNull Pattern<Icon> pattern,
int startRow,
int startColumn,
int endRow,
int endColumn)
fills the inventory with the given
Pattern. |
default @NotNull InventoryContents |
fillPatternRepeating(@NotNull Pattern<Icon> pattern,
@NotNull SlotPos startPos,
@NotNull SlotPos endPos)
fills the inventory with the given
Pattern. |
default @NotNull InventoryContents |
fillRect(int fromIndex,
int toIndex,
@NotNull Icon item)
fills a rectangle inside the inventory using the given
positions.
|
default @NotNull InventoryContents |
fillRect(int fromRow,
int fromColumn,
int toRow,
int toColumn,
@NotNull Icon item)
same as
fillRect(int, int, Icon),
but with SlotPos instead of the indexes. |
default @NotNull InventoryContents |
fillRect(@NotNull SlotPos fromPos,
@NotNull SlotPos toPos,
@NotNull Icon item)
same as
fillRect(int, int, Icon),
but with rows and columns instead of the indexes. |
default @NotNull InventoryContents |
fillRow(int row,
@NotNull Icon item)
fills the given inventory row with the given item.
|
default @NotNull InventoryContents |
fillSquare(int fromIndex,
int toIndex,
@NotNull Icon item)
completely fills the provided square with the given
Icon. |
default @NotNull InventoryContents |
fillSquare(int fromRow,
int fromColumn,
int toRow,
int toColumn,
@NotNull Icon item)
completely fills the provided square with the given
Icon. |
default @NotNull InventoryContents |
fillSquare(@NotNull SlotPos fromPos,
@NotNull SlotPos toPos,
@NotNull Icon item)
completely fills the provided square with the given
Icon. |
default @NotNull Optional<SlotPos> |
findItem(@NotNull Icon item)
looks for the given icon and compares them using
ItemStack.isSimilar(ItemStack),
ignoring the amount. |
default @NotNull Optional<SlotPos> |
findItem(@NotNull org.bukkit.inventory.ItemStack item)
looks for the given item and compares them using
ItemStack.isSimilar(ItemStack),
ignoring the amount. |
default @NotNull Optional<SlotPos> |
firstEmpty()
returns the position of the first empty slot
in the inventory, or
Optional.empty() if
there is no free slot. |
default @NotNull Optional<Icon> |
get(int index)
returns the item in the inventory at the given
slot index, or
Optional.empty() if
the slot is empty or if the index is out of bounds. |
default @NotNull Optional<Icon> |
get(int row,
int column)
same as
get(int),
but with a row and a column instead of the index. |
default @NotNull Optional<Icon> |
get(@NotNull SlotPos slotPos)
|
default @NotNull org.bukkit.inventory.Inventory |
getBottomInventory()
gets player's bottom of the inventory.
|
<T> T |
getProperty(@NotNull String name)
gets the value of the property with the given name.
|
<T> T |
getPropertyOrDefault(@NotNull String name,
T def)
gets the value of the property with the given name,
or a default value if the property isn't set.
|
default @NotNull org.bukkit.inventory.Inventory |
getTopInventory()
gets player's top of the inventory.
|
boolean |
isEditable(@NotNull SlotPos slot)
returns if a given slot is editable or not.
|
@NotNull Optional<SlotIterator> |
iterator(@NotNull String id)
gets a previously registered iterator named with the given id.
|
default @NotNull SlotIterator |
newIterator(SlotIterator.Type type,
int startRow,
int startColumn)
creates and returns an iterator.
|
default @NotNull SlotIterator |
newIterator(SlotIterator.Type type,
@NotNull SlotPos startPos)
same as
newIterator(SlotIterator.Type, int, int),
but using a SlotPos instead. |
@NotNull SlotIterator |
newIterator(@NotNull String id,
SlotIterator.Type type,
int startRow,
int startColumn)
creates and registers an iterator using a given id.
|
default @NotNull SlotIterator |
newIterator(@NotNull String id,
SlotIterator.Type type,
@NotNull SlotPos startPos)
same as
newIterator(String, SlotIterator.Type, int, int),
but using a SlotPos instead. |
default void |
notifyUpdate()
runs
Page.notifyUpdate(InventoryContents) method of this. |
default void |
notifyUpdateForAll()
runs
Page.notifyUpdateForAll() method of this. |
default void |
notifyUpdateForAllById()
runs
Page.notifyUpdateForAllById() method of this. |
default void |
openNext()
opens the next page with using
Pagination. |
default void |
openPrevious()
opens the previous page with using
Pagination. |
@NotNull Page |
page()
obtains the page of the
this. |
@NotNull Pagination |
pagination()
gets the pagination system linked to
this. |
@NotNull org.bukkit.entity.Player |
player()
obtains the player of the contents.
|
default void |
removeAll(@NotNull Icon item)
removes all occurrences of the item from the inventory.
|
default void |
removeAll(@NotNull org.bukkit.inventory.ItemStack item)
removes all occurrences of the item from the inventory.
|
default void |
removeAmount(@NotNull Icon item,
int amount)
removes the specified amount of items from the inventory.
|
default void |
removeAmount(@NotNull org.bukkit.inventory.ItemStack item,
int amount)
removes the specified amount of items from the inventory.
|
default void |
removeFirst(@NotNull Icon item)
clears the first slot where the given item is in.
|
default void |
removeFirst(@NotNull org.bukkit.inventory.ItemStack item)
clears the first slot where the given item is in.
|
default void |
reopen()
re open the current page.
|
default @NotNull InventoryContents |
set(int index,
@Nullable Icon item)
sets the item in the inventory at the given
slot index.
|
@NotNull InventoryContents |
set(int row,
int column,
@Nullable Icon item)
same as
set(int, Icon),
but with a row and a column instead of the index. |
default @NotNull InventoryContents |
set(@NotNull SlotPos slotPos,
@Nullable Icon item)
Same as
set(int, Icon),
but with a SlotPos instead of the index. |
default InventoryContents |
setEditable(@NotNull SlotPos slot)
makes a slot editable, which enables the player to
put items in and take items out of the inventory in the
specified slot.
|
InventoryContents |
setEditable(@NotNull 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.
|
@NotNull InventoryContents |
setProperty(@NotNull String name,
@NotNull Object value)
sets the value of the property with the given name.
|
default @NotNull List<SlotPos> |
slots()
returns a list of all the slots in the inventory.
|
@NotNull default @NotNull SlotIterator newIterator(@NotNull SlotIterator.Type type, int startRow, int startColumn)
this does NOT registers the iterator,
thus iterator(String) will not be
able to return the iterators created with this method.
type - the type of the iterator.startRow - the starting row of the iterator.startColumn - the starting column of the iterator.@NotNull default @NotNull SlotIterator newIterator(@NotNull @NotNull String id, @NotNull SlotIterator.Type type, @NotNull @NotNull SlotPos startPos)
newIterator(String, SlotIterator.Type, int, int),
but using a SlotPos instead.id - the id of the iterator.type - the type of the iterator.startPos - the starting position of the iterator.@NotNull default @NotNull SlotIterator newIterator(@NotNull SlotIterator.Type type, @NotNull @NotNull SlotPos startPos)
newIterator(SlotIterator.Type, int, int),
but using a SlotPos instead.type - the type of the iterator.startPos - the starting position of the iterator.@NotNull default @NotNull List<SlotPos> slots()
@NotNull default @NotNull Optional<SlotPos> firstEmpty()
Optional.empty() if
there is no free slot.@NotNull default @NotNull Optional<Icon> get(int index)
Optional.empty() if
the slot is empty or if the index is out of bounds.index - the slot index.@NotNull default @NotNull Optional<Icon> get(int row, int column)
get(int),
but with a row and a column instead of the index.row - the row to get.column - the colum to get.@NotNull default @NotNull Optional<Icon> get(@NotNull @NotNull SlotPos slotPos)
slotPos - the slot position to get.@NotNull default @NotNull InventoryContents applyRect(int fromRow, int fromColumn, int toRow, int toColumn, @NotNull @NotNull ObjIntConsumer<Integer> apply)
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.
fromColumn - the from column to apply.fromRow - the from row to apply.toColumn - the to column to apply.toRow - the to row to apply.apply - the apply to accept row and columnthis, for chained calls@NotNull default @NotNull InventoryContents applyRect(int fromRow, int fromColumn, int toRow, int toColumn, @NotNull @NotNull Consumer<Icon> apply)
Icon 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.
fromColumn - the from column to apply.fromRow - the from row to apply.toColumn - the to column to apply.toRow - the to row to apply.apply - the apply to accept each slotthis, for chained calls@NotNull default @NotNull InventoryContents set(int index, @Nullable @Nullable Icon item)
index - the slot index.item - the item to set, or null to clear the slotthis, for chained calls.@NotNull default @NotNull InventoryContents set(@NotNull @NotNull SlotPos slotPos, @Nullable @Nullable Icon item)
set(int, Icon),
but with a SlotPos instead of the index.slotPos - the slotPos to set.item - the item to set.this, for chained calls.@NotNull default @NotNull InventoryContents add(@NotNull @NotNull Icon item)
item - the item to add.this, for chained calls.@NotNull default @NotNull Optional<SlotPos> findItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
ItemStack.isSimilar(ItemStack),
ignoring the amount.
this method searches row for row from left to right.
item - the item to look for.@NotNull default @NotNull Optional<SlotPos> findItem(@NotNull @NotNull Icon item)
ItemStack.isSimilar(ItemStack),
ignoring the amount.
this method searches row for row from left to right.
item - the item with the item stack to look for.default void removeFirst(@NotNull
@NotNull org.bukkit.inventory.ItemStack item)
the items will be compared using ItemStack.isSimilar(ItemStack) to check if the are equal.
the amount stored in the item is ignored for simplicity.
item - the item as an ItemStack that shall be removed from the inventory.default void removeFirst(@NotNull
@NotNull Icon item)
the items will be compared using ItemStack.isSimilar(ItemStack) to check if the are equal.
Icon.getItem() is used to get the item that will be compared against
the amount stored in the item is ignored for simplicity.
item - the item as a Icon that shall be removed from the inventory.default void removeAmount(@NotNull
@NotNull org.bukkit.inventory.ItemStack item,
int amount)
the items will be compared using ItemStack.isSimilar(ItemStack) to check if the are equal.
item - the item as an ItemStack that shall be removed from the inventory.amount - the amount that shall be removed.default void removeAmount(@NotNull
@NotNull Icon item,
int amount)
the items will be compared using ItemStack.isSimilar(ItemStack) to check if the are equal.
Icon.getItem() is used to get the item that will be compared against
item - the item as a Icon that shall be removed from the inventory.amount - the amount that shall be removed.default void removeAll(@NotNull
@NotNull org.bukkit.inventory.ItemStack item)
the items will be compared using ItemStack.isSimilar(ItemStack) to check if the are equal.
item - the item as an ItemStack that shall be removed from the inventory.default void removeAll(@NotNull
@NotNull Icon item)
the items will be compared using ItemStack.isSimilar(ItemStack) to check if the are equal.
Icon.getItem() is used to get the item that will be compared against.
item - the item as an Icon that shall be removed from the inventory.@NotNull default @NotNull InventoryContents fill(@NotNull @NotNull Icon item)
item - the item to fill.this, for chained calls.@NotNull default @NotNull InventoryContents fillEmpties(@NotNull @NotNull Icon item)
item - the item to fill.this, for chained calls.@NotNull default @NotNull InventoryContents fillRow(int row, @NotNull @NotNull Icon item)
row - the row to fill.item - the item to fill.this, for chained calls.@NotNull default @NotNull InventoryContents fillColumn(int column, @NotNull @NotNull Icon item)
column - the column to fill.item - the item to fill.this, for chained calls.@NotNull default @NotNull InventoryContents fillBorders(@NotNull @NotNull Icon item)
item - the item to fill.this, for chained calls.@NotNull default @NotNull InventoryContents fillRect(int fromIndex, int toIndex, @NotNull @NotNull Icon item)
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.
fromIndex - the slot index at the top-left position.toIndex - the slot index at the bottom-right position.item - the item to fill.this, for chained calls.@NotNull default @NotNull InventoryContents fillRect(int fromRow, int fromColumn, int toRow, int toColumn, @NotNull @NotNull Icon item)
fillRect(int, int, Icon),
but with SlotPos instead of the indexes.fromRow - the row of the first corner of the rect.fromColumn - the column of the first corner of the rect.toRow - the row of the second corner of the rect.toColumn - the column of the second corner of the rect.item - the item to fill the rect with.this, for chained calls.fillRect(int, int, Icon)@NotNull default @NotNull InventoryContents fillRect(@NotNull @NotNull SlotPos fromPos, @NotNull @NotNull SlotPos toPos, @NotNull @NotNull Icon item)
fillRect(int, int, Icon),
but with rows and columns instead of the indexes.fromPos - the first corner of the rect.toPos - the second corner of the rect.item - the item to fill the rect with.this, for chained calls.fillRect(int, int, Icon)@NotNull default @NotNull InventoryContents fillSquare(int fromIndex, int toIndex, @NotNull @NotNull Icon item)
Icon.fromIndex - the slot index of the upper left corner.toIndex - the slot index of the lower right corner.item - the item.this, for chained calls.@NotNull default @NotNull InventoryContents fillSquare(int fromRow, int fromColumn, int toRow, int toColumn, @NotNull @NotNull Icon item)
Icon.fromRow - the row of the upper left corner.fromColumn - the column of the upper-left corner.toRow - the row of the lower right corner.toColumn - the column of the lower right corner.item - the item.this, for chained calls.@NotNull default @NotNull InventoryContents fillSquare(@NotNull @NotNull SlotPos fromPos, @NotNull @NotNull SlotPos toPos, @NotNull @NotNull Icon item)
Icon.fromPos - the slot position of the upper left corner.toPos - the slot position of the lower right corner.item - the item.this, for chained calls.@NotNull default @NotNull InventoryContents fillPattern(@NotNull @NotNull Pattern<Icon> pattern)
Pattern.
the pattern will start at the first slot.
pattern - the filling pattern.this, for chained calls.to fill the pattern from the provided slot index.,
to fill the pattern from the provided row and column.,
to fill the pattern from the provided slot pos.@NotNull default @NotNull InventoryContents fillPattern(@NotNull @NotNull Pattern<Icon> pattern, int startIndex)
Pattern.
the pattern will start at the given slot index.
pattern - the filling pattern.startIndex - the start slot index for the filling.this, for chained calls.to fill the pattern from the first slot.,
to fill the pattern from the provided row and column.,
to fill the pattern from the provided slot pos.@NotNull default @NotNull InventoryContents fillPattern(@NotNull @NotNull Pattern<Icon> pattern, int startRow, int startColumn)
Pattern.
the pattern will start at the given slot position based on the provided row and column.
pattern - the filling pattern.startRow - the start row of the slot for filling.startColumn - the start column of the slot for filling.this, for chained calls.to fill the pattern from the first slot.,
to fill the pattern from the provided slot index.,
to fill the pattern from the provided slot pos.@NotNull default @NotNull InventoryContents fillPattern(@NotNull @NotNull Pattern<Icon> pattern, @NotNull @NotNull SlotPos startPos)
Pattern.
the pattern will start at the given slot position.
pattern - the filling pattern.startPos - the start position of the slot for filling.this, for chained calls.to fill the pattern from the first slot.,
to fill the pattern from the provided slot index.,
to fill the pattern from the provided row and column.@NotNull default @NotNull InventoryContents fillPatternRepeating(@NotNull @NotNull Pattern<Icon> pattern)
Pattern.
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 with wrapAround enabled.
pattern - the filling pattern.this, for chained calls.to fill a repeating pattern using slot indexes.,
to fill a repeating pattern using slot positions contructed
from their rows and columns.,
to fill a repeating pattern using slot positions.@NotNull default @NotNull InventoryContents fillPatternRepeating(@NotNull @NotNull Pattern<Icon> pattern, int startIndex, int endIndex)
Pattern.
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.
if endIndex is a negative value it is set to the bottom-right corner.
for this to work the pattern needs to be created with wrapAround enabled.
pattern - the filling pattern.startIndex - the start slot index where the pattern should begin.endIndex - the end slot index where the pattern should end.this, for chained calls.to fill a repeating pattern into the whole inventory.,
to fill a repeating pattern using slot positions contructed
from their rows and columns.,
to fill a repeating pattern using slot positions.@NotNull default @NotNull InventoryContents fillPatternRepeating(@NotNull @NotNull Pattern<Icon> pattern, int startRow, int startColumn, int endRow, int endColumn)
Pattern.
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 endRow is a negative value, endRow is automatically set to the max row size,
if endColumn is a negative value, endColumn is automatically set to the max column size.
for this to work the pattern needs to be created with wrapAround enabled.
pattern - the filling pattern.startRow - the start row of the slot for filling.startColumn - the start column of the slot for filling.endRow - the end row of the slot for filling.endColumn - the end column of the slot for filling.this, for chained calls.to fill a repeating pattern into the whole inventory.,
to fill a repeating pattern using slot indexes.,
to fill a repeating pattern using slot positions.@NotNull default @NotNull InventoryContents fillPatternRepeating(@NotNull @NotNull Pattern<Icon> pattern, @NotNull @NotNull SlotPos startPos, @NotNull @NotNull SlotPos endPos)
Pattern.
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 of endPos is a negative value, endRow is automatically set to the max row size,
if the column of endPos is a negative value, endColumn is automatically set to the max column size.
for this to work the pattern needs to be created with wrapAround enabled.
pattern - the filling pattern.startPos - the position where the pattern should start.endPos - the position where the pattern should end.this, for chained calls.to fill a repeating pattern into the whole inventory.,
to fill a repeating pattern using slot indexes.,
to fill a repeating pattern using slot positions contructed
from their rows and columns.@NotNull default @NotNull org.bukkit.inventory.Inventory getBottomInventory()
@NotNull default @NotNull org.bukkit.inventory.Inventory getTopInventory()
default void reopen()
default void openNext()
Pagination.default void openPrevious()
Pagination.default void notifyUpdate()
Page.notifyUpdate(InventoryContents) method of this.default void notifyUpdateForAll()
Page.notifyUpdateForAll() method of this.default void notifyUpdateForAllById()
Page.notifyUpdateForAllById() method of this.default InventoryContents setEditable(@NotNull @NotNull SlotPos slot)
slot - the slot to set editable.this, for chained calls.@NotNull @NotNull Page page()
this.@NotNull @NotNull Pagination pagination()
this.@NotNull @NotNull Icon[][] all()
Icon containing
all the items of the inventory.
the Icons can be null when there is no
item in the corresponding slot.
@NotNull @NotNull org.bukkit.entity.Player player()
@NotNull @NotNull Optional<SlotIterator> iterator(@NotNull @NotNull String id)
if no iterator is found, this will return Optional.empty().
id - the id of the iterator.@Nullable
<T> T getProperty(@NotNull
@NotNull String name)
T - the type of the value.name - the property's name.@NotNull
<T> T getPropertyOrDefault(@NotNull
@NotNull String name,
@NotNull
T def)
T - the type of the value.name - the property's name.def - the default value.@NotNull @NotNull SlotIterator newIterator(@NotNull @NotNull String id, @NotNull SlotIterator.Type type, int startRow, int startColumn)
you can retrieve the iterator at any time using
the iterator(String) method.
id - the id of the iterator.type - the type of the iterator.startRow - the starting row of the iterator.startColumn - the starting column of the iterator.@NotNull @NotNull InventoryContents set(int row, int column, @Nullable @Nullable Icon item)
set(int, Icon),
but with a row and a column instead of the index.row - the row to set.column - the column to set.item - the item to set.this, for chained calls.@NotNull @NotNull InventoryContents setProperty(@NotNull @NotNull String name, @NotNull @NotNull Object value)
this will replace the existing value for the property, if there is one.
name - the property's name.value - the new property's value.this, for chained calls.InventoryContents setEditable(@NotNull @NotNull SlotPos slot, boolean editable)
slot - the slot to set editable.editable - true to make a slot editable, false
to make it 'static' again.this, for chained calls.boolean isEditable(@NotNull
@NotNull SlotPos slot)
slot - The slot to check.true if the editable.Copyright © 2021. All rights reserved.