Package org.yuemi.libs.api.items
Interface ItemsApi
public interface ItemsApi
Interface to manage item providers and query items using NAMESPACE:ID keys.
-
Method Summary
Modifier and TypeMethodDescription@Nullable org.bukkit.inventory.ItemStackGets an item stack by its namespace and ID key (e.g.intgetItemCount(@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.booleanGives an item by namespace and ID key to the player.voidregisterProvider(@NotNull String namespace, @NotNull ItemProvider provider) Registers a provider under a specific namespace.booleanTakes an item by namespace and ID key from the player.
-
Method Details
-
registerProvider
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 keyamount- 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 playerkey- the namespace:id keyamount- 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 playerkey- the namespace:id keyamount- the item quantity to take- Returns:
- true if successful, false otherwise
-
getItemCount
Gets the count of matching items by namespace and ID key in the player's inventory.- Parameters:
player- the playerkey- the namespace:id key- Returns:
- the count of matching items
-