Package dev.itsharshxd.zentrix.api.item
Interface ZentrixItem
public interface ZentrixItem
Read-only view of a custom item definition.
Addons can register these items for use in phases, player classes, and other game mechanics. Items may come from ItemsAdder or Nexo.
Example
ItemService service = ZentrixAPI.get().getItemService();
// Get the item definition
Optional<ZentrixItem> item = service.getItemDefinition("tracking-compass");
item.ifPresent(def -> {
System.out.println("Item: " + def.getId());
System.out.println("Material: " + def.getMaterial());
System.out.println("Display Name: " + def.getDisplayName());
// Create an ItemStack
ItemStack stack = def.toItemStack();
player.getInventory().addItem(stack);
});
- Since:
- 1.1.0
-
Method Summary
Modifier and TypeMethodDescriptionGets the addon ID that registered this item.intGets the default amount for this item.Gets custom metadata fields for this item.intGets the custom model data for this item.@NotNull StringGets the display name for this item.Gets the enchantments applied to this item.Gets the external source identifier for this item.@NotNull Set<org.bukkit.inventory.ItemFlag> getFlags()Gets the item flags applied to this item.@NotNull StringgetId()Gets the unique identifier for this item.getLore()Gets the lore lines for this item.@NotNull org.bukkit.MaterialGets the base material for this item.intgetSlot()Gets the preferred inventory slot for this item.booleanReturns whether an addon registered this item at runtime.booleanChecks if this item is enabled.booleanChecks if this item uses an external source (ItemsAdder, Nexo, etc.).booleanisGlow()Checks if this item has a glow effect.booleanChecks if this item is unbreakable.@NotNull org.bukkit.inventory.ItemStackCreates a usable ItemStack from this item definition.@NotNull org.bukkit.inventory.ItemStacktoItemStack(int amount) Creates a usable ItemStack with a specific amount.
-
Method Details
-
getId
Gets the unique identifier for this item.- Returns:
- The item ID (never null)
-
getMaterial
@NotNull @NotNull org.bukkit.Material getMaterial()Gets the base material for this item.For external items, this may return the fallback material.
- Returns:
- The material (never null)
-
getExternalSource
Gets the external source identifier for this item.Format: "itemsadder:namespace:id" or "nexo:id"
- Returns:
- Optional containing the external source, or empty if vanilla/custom
-
isExternal
boolean isExternal()Checks if this item uses an external source (ItemsAdder, Nexo, etc.).- Returns:
trueif external
-
getDisplayName
Gets the display name for this item.- Returns:
- The display name with color codes (never null)
-
getLore
Gets the lore lines for this item.- Returns:
- An unmodifiable list of lore lines (never null, may be empty)
-
getAmount
int getAmount()Gets the default amount for this item.- Returns:
- The item amount
-
getEnchantments
Gets the enchantments applied to this item.- Returns:
- An unmodifiable map of enchantments to levels (never null, may be empty)
-
getFlags
Gets the item flags applied to this item.- Returns:
- An unmodifiable set of item flags (never null, may be empty)
-
getCustomModelData
int getCustomModelData()Gets the custom model data for this item.Returns 0 if not set.
- Returns:
- The custom model data value
-
isUnbreakable
boolean isUnbreakable()Checks if this item is unbreakable.- Returns:
trueif unbreakable
-
isGlow
boolean isGlow()Checks if this item has a glow effect.- Returns:
trueif glowing
-
getSlot
int getSlot()Gets the preferred inventory slot for this item.Returns -1 if no specific slot is configured.
- Returns:
- The slot index (0-8 for hotbar), or -1 if not specified
-
isEnabled
boolean isEnabled()Checks if this item is enabled.- Returns:
trueif enabled
-
toItemStack
@NotNull @NotNull org.bukkit.inventory.ItemStack toItemStack()Creates a usable ItemStack from this item definition.The returned ItemStack is a clone and safe to modify.
- Returns:
- A new ItemStack (never null)
-
toItemStack
@NotNull @NotNull org.bukkit.inventory.ItemStack toItemStack(int amount) Creates a usable ItemStack with a specific amount.The returned ItemStack is a clone and safe to modify.
- Parameters:
amount- The item amount- Returns:
- A new ItemStack with the specified amount (never null)
-
getAddonId
Gets the addon ID that registered this item.- Returns:
- Optional containing the addon ID, or empty if not addon-registered
-
isDynamicallyRegistered
boolean isDynamicallyRegistered()Returns whether an addon registered this item at runtime.- Returns:
trueif dynamically registered
-
getCustomFields
Gets custom metadata fields for this item.- Returns:
- An unmodifiable map of custom fields (never null, may be empty)
-