Interface ItemsApi


public interface ItemsApi
Interface to manage item providers and query items using NAMESPACE:ID keys.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable org.bukkit.inventory.ItemStack
    getItem(@NotNull String key, int amount)
    Gets an item stack by its namespace and ID key (e.g.
    int
    getItemCount(@NotNull org.bukkit.entity.Player player, @NotNull String key)
    Gets the count of matching items by namespace and ID key in the player's inventory.
    boolean
    giveItem(@NotNull org.bukkit.entity.Player player, @NotNull String key, int amount)
    Gives an item by namespace and ID key to the player.
    void
    registerProvider(@NotNull String namespace, @NotNull ItemProvider provider)
    Registers a provider under a specific namespace.
    boolean
    takeItem(@NotNull org.bukkit.entity.Player player, @NotNull String key, int amount)
    Takes an item by namespace and ID key from the player.
  • Method Details

    • registerProvider

      void registerProvider(@NotNull @NotNull String namespace, @NotNull @NotNull ItemProvider provider)
      Registers a provider under a specific namespace.
      Parameters:
      namespace - the namespace (e.g. "minecraft")
      provider - the item provider
    • getItem

      @Nullable @Nullable org.bukkit.inventory.ItemStack getItem(@NotNull @NotNull String key, int amount)
      Gets an item stack by its namespace and ID key (e.g. "minecraft:stone").
      Parameters:
      key - the namespace:id key
      amount - the item quantity
      Returns:
      the item stack, or null if provider/item is not found
    • giveItem

      boolean giveItem(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String key, int amount)
      Gives an item by namespace and ID key to the player.
      Parameters:
      player - the player
      key - the namespace:id key
      amount - the item quantity
      Returns:
      true if successful, false otherwise
    • takeItem

      boolean takeItem(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String key, int amount)
      Takes an item by namespace and ID key from the player.
      Parameters:
      player - the player
      key - the namespace:id key
      amount - the item quantity to take
      Returns:
      true if successful, false otherwise
    • getItemCount

      int getItemCount(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String key)
      Gets the count of matching items by namespace and ID key in the player's inventory.
      Parameters:
      player - the player
      key - the namespace:id key
      Returns:
      the count of matching items