Interface ItemManager
public interface ItemManager
An interface to manage
BoxItems.-
Method Summary
Modifier and TypeMethodDescriptiongetBoxItem(int id) Gets theBoxItemof the specified id if it exists.getBoxItem(@NotNull String name) Gets theBoxItemof the specified name if it exists.getBoxItem(@NotNull org.bukkit.inventory.ItemStack itemStack) Gets theBoxItemof the specified item if it exists.@Nullable BoxItemgetBoxItemOrNull(int id) Gets theBoxItemof the specified id if it exists.@NotNull it.unimi.dsi.fastutil.ints.IntImmutableListGets a list of item ids.@NotNull it.unimi.dsi.fastutil.objects.ObjectImmutableList<BoxItem> Gets a list of registeredBoxItems.@NotNull UnaryOperator<String> getItemNameConverter(@NotNull MCDataVersion sourceVersion) Get theUnaryOperatorthat converts the default item name from the specifiedMCDataVersionto the currentMCDataVersion.@NotNull it.unimi.dsi.fastutil.objects.ObjectImmutableList<String> Gets a list of item names@NotNull it.unimi.dsi.fastutil.ints.Int2IntMapGet the remapped item ids.booleanisCustomItem(@NotNull BoxItem item) Checks if the specified item is a custom item created by box itself.booleanisRegistered(@NotNull org.bukkit.inventory.ItemStack itemStack) Checks if the specified item has already been registered.booleanisUsedName(@NotNull String name) Checks if the specified name has already been used.voidregisterCustomItem(@NotNull org.bukkit.inventory.ItemStack original, @Nullable String plainName, @NotNull Consumer<ItemRegistrationResult> resultConsumer) Registers a new item.voidrenameCustomItem(@NotNull BoxCustomItem item, @NotNull String newName, @NotNull Consumer<ItemRenameResult> resultConsumer) Renames aBoxCustomItem.
-
Method Details
-
getBoxItem
@NotNull @NotNull Optional<BoxItem> getBoxItem(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Gets theBoxItemof the specified item if it exists.- Parameters:
itemStack- the item to get- Returns:
- the optional
BoxItem
-
getBoxItem
Gets theBoxItemof the specified name if it exists.- Parameters:
name- the item name to get- Returns:
- the optional
BoxItem
-
getBoxItem
Gets theBoxItemof the specified id if it exists.- Parameters:
id- the id to get- Returns:
- the optional
BoxItem
-
getBoxItemOrNull
Gets theBoxItemof the specified id if it exists.- Parameters:
id- the id to get- Returns:
- the
BoxItemor null
-
getItemIdList
@NotNull @NotNull it.unimi.dsi.fastutil.ints.IntImmutableList getItemIdList()Gets a list of item ids.This method returns a collection of
BoxItem.getInternalId().- Returns:
- an immutable list of
BoxItem.getInternalId()
-
getItemNameList
Gets a list of item namesThis method returns a collection of
BoxItem.getPlainName().- Returns:
- an immutable list of
BoxItem.getPlainName()
-
getItemList
Gets a list of registeredBoxItems.- Returns:
- an immutable list of
BoxItems
-
isRegistered
boolean isRegistered(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Checks if the specified item has already been registered.- Parameters:
itemStack- the item to check- Returns:
trueif registered,falseotherwise
-
isUsedName
Checks if the specified name has already been used.- Parameters:
name- the name to check- Returns:
trueif used,falseotherwise
-
isCustomItem
Checks if the specified item is a custom item created by box itself.- Parameters:
item- the item to check- Returns:
trueif the item is a custom item,falseotherwise
-
registerCustomItem
void registerCustomItem(@NotNull @NotNull org.bukkit.inventory.ItemStack original, @Nullable @Nullable String plainName, @NotNull @NotNull Consumer<ItemRegistrationResult> resultConsumer) Registers a new item.The registration process will be executed on different thread, and this method does not wait for that process to complete. The
ConsumerofItemRegistrationResultwill be called on that thread.- Parameters:
original- the item to registerplainName- the name of the itemresultConsumer- aConsumer, which will be called when completed registration process
-
renameCustomItem
void renameCustomItem(@NotNull @NotNull BoxCustomItem item, @NotNull @NotNull String newName, @NotNull @NotNull Consumer<ItemRenameResult> resultConsumer) Renames aBoxCustomItem.The rename process will be executed on different thread, and this method does not wait for that process to complete. The
ConsumerofItemRegistrationResultwill be called on that thread.- Parameters:
item- aBoxCustomItemto renamenewName- a new nameresultConsumer- aConsumer, which will be called when completed rename process- Throws:
IllegalArgumentException-BoxCustomItemis not created by Box (isCustomItem(BoxItem)returnsfalse)
-
getItemNameConverter
@NotNull @NotNull UnaryOperator<String> getItemNameConverter(@NotNull @NotNull MCDataVersion sourceVersion) Get theUnaryOperatorthat converts the default item name from the specifiedMCDataVersionto the currentMCDataVersion.- Parameters:
sourceVersion- the version of item names to be converted- Returns:
- the
UnaryOperatorthat converts the default item name
-
getRemappedItemIds
@NotNull @NotNull it.unimi.dsi.fastutil.ints.Int2IntMap getRemappedItemIds()Get the remapped item ids.- Returns:
- the remapped item ids
-