Interface ItemManager


public interface ItemManager
An interface to manage BoxItems.
  • Method Details

    • getBoxItem

      @NotNull @NotNull Optional<BoxItem> getBoxItem(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Gets the BoxItem of the specified item if it exists.
      Parameters:
      itemStack - the item to get
      Returns:
      the optional BoxItem
    • getBoxItem

      @NotNull @NotNull Optional<BoxItem> getBoxItem(@NotNull @NotNull String name)
      Gets the BoxItem of the specified name if it exists.
      Parameters:
      name - the item name to get
      Returns:
      the optional BoxItem
    • getBoxItem

      @NotNull @NotNull Optional<BoxItem> getBoxItem(int id)
      Gets the BoxItem of the specified id if it exists.
      Parameters:
      id - the id to get
      Returns:
      the optional BoxItem
    • getBoxItemOrNull

      @Nullable @Nullable BoxItem getBoxItemOrNull(int id)
      Gets the BoxItem 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

      @NotNull @NotNull it.unimi.dsi.fastutil.objects.ObjectImmutableList<String> getItemNameList()
      Gets a list of item names

      This method returns a collection of BoxItem.getPlainName().

      Returns:
      an immutable list of BoxItem.getPlainName()
    • getItemList

      @NotNull @NotNull it.unimi.dsi.fastutil.objects.ObjectImmutableList<BoxItem> getItemList()
      Gets a list of registered BoxItems.
      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:
      true if registered, false otherwise
    • isUsedName

      boolean isUsedName(@NotNull @NotNull String name)
      Checks if the specified name has already been used.
      Parameters:
      name - the name to check
      Returns:
      true if used, false otherwise
    • isCustomItem

      boolean isCustomItem(@NotNull @NotNull BoxItem item)
      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 of ItemRegistrationResult will be called on that thread.

      Parameters:
      original - the item to register
      plainName - the name of the item
      resultConsumer - a Consumer, 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 a BoxCustomItem.

      The rename process will be executed on different thread, and this method does not wait for that process to complete. The Consumer of ItemRegistrationResult will be called on that thread.

      Parameters:
      item - a BoxCustomItem to rename
      newName - a new name
      resultConsumer - a Consumer, which will be called when completed rename process
      Throws:
      IllegalArgumentException - BoxCustomItem is not created by Box (isCustomItem(BoxItem) returns false)
    • getItemNameConverter

      @NotNull @NotNull UnaryOperator<String> getItemNameConverter(@NotNull @NotNull MCDataVersion sourceVersion)
      Get the UnaryOperator that converts the default item name from the specified MCDataVersion to the current MCDataVersion.
      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