Interface ItemManager
public interface ItemManager
An interface to manage
BoxItem
s.-
Method Summary
Modifier and TypeMethodDescriptiongetBoxItem
(int id) Gets theBoxItem
of the specified id if it exists.getBoxItem
(@NotNull String name) Gets theBoxItem
of the specified name if it exists.getBoxItem
(@NotNull org.bukkit.inventory.ItemStack itemStack) Gets theBoxItem
of the specified item if it exists.@Nullable BoxItem
getBoxItemOrNull
(int id) Gets theBoxItem
of the specified id if it exists.@NotNull it.unimi.dsi.fastutil.ints.IntImmutableList
Gets a list of item ids.@NotNull it.unimi.dsi.fastutil.objects.ObjectImmutableList
<BoxItem> Gets a list of registeredBoxItem
s.@NotNull UnaryOperator
<String> getItemNameConverter
(@NotNull MCDataVersion sourceVersion) Get theUnaryOperator
that converts the default item name from the specifiedMCDataVersion
to the currentMCDataVersion
.@NotNull it.unimi.dsi.fastutil.objects.ObjectImmutableList
<String> Gets a list of item names@NotNull it.unimi.dsi.fastutil.ints.Int2IntMap
Get the remapped item ids.boolean
isCustomItem
(@NotNull BoxItem item) Checks if the specified item is a custom item created by box itself.boolean
isRegistered
(@NotNull org.bukkit.inventory.ItemStack itemStack) Checks if the specified item has already been registered.boolean
isUsedName
(@NotNull String name) Checks if the specified name has already been used.void
registerCustomItem
(@NotNull org.bukkit.inventory.ItemStack original, @Nullable String plainName, @NotNull Consumer<ItemRegistrationResult> resultConsumer) Registers a new item.void
renameCustomItem
(@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 theBoxItem
of the specified item if it exists.- Parameters:
itemStack
- the item to get- Returns:
- the optional
BoxItem
-
getBoxItem
Gets theBoxItem
of the specified name if it exists.- Parameters:
name
- the item name to get- Returns:
- the optional
BoxItem
-
getBoxItem
Gets theBoxItem
of the specified id if it exists.- Parameters:
id
- the id to get- Returns:
- the optional
BoxItem
-
getBoxItemOrNull
Gets theBoxItem
of the specified id if it exists.- Parameters:
id
- the id to get- Returns:
- the
BoxItem
or 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 registeredBoxItem
s.- Returns:
- an immutable list of
BoxItem
s
-
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:
true
if registered,false
otherwise
-
isUsedName
Checks if the specified name has already been used.- Parameters:
name
- the name to check- Returns:
true
if used,false
otherwise
-
isCustomItem
Checks if the specified item is a custom item created by box itself.- Parameters:
item
- the item to check- Returns:
true
if the item is a custom item,false
otherwise
-
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
Consumer
ofItemRegistrationResult
will 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
Consumer
ofItemRegistrationResult
will be called on that thread.- Parameters:
item
- aBoxCustomItem
to renamenewName
- a new nameresultConsumer
- aConsumer
, which will be called when completed rename process- Throws:
IllegalArgumentException
-BoxCustomItem
is not created by Box (isCustomItem(BoxItem)
returnsfalse
)
-
getItemNameConverter
@NotNull @NotNull UnaryOperator<String> getItemNameConverter(@NotNull @NotNull MCDataVersion sourceVersion) Get theUnaryOperator
that converts the default item name from the specifiedMCDataVersion
to the currentMCDataVersion
.- Parameters:
sourceVersion
- the version of item names to be converted- Returns:
- the
UnaryOperator
that 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
-