Class CustomStack
java.lang.Object
dev.lone.itemsadder.api.CustomStack
- Direct Known Subclasses:
CustomBlock, CustomFire, CustomFurniture
Wrapper for an ItemsAdder custom item stack.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable CustomStackbyItemStack(ItemStack itemStack) Returns null if the provided ItemStack is not a custom item created with ItemsAdderbooleanDrops this item stack naturally at a location.Gets the configuration file that defines this custom item.Gets the configuration file path that defines this custom item.Gets a copy of this custom item's merged configuration section.getConfigSectionCopy(boolean merged) Gets a copy of this custom item's configuration section.static ConfigurationSectiongetConfigSectionCopy(ItemStack itemStack) Gets a copy of the merged configuration section for a custom item stack.static ConfigurationSectiongetConfigSectionCopy(ItemStack itemStack, boolean merged) Gets a copy of the configuration section for a custom item stack.static longgetCooldownMs(Player player, ItemStack customItemStack) Gets the remaining cooldown for a custom item stack.doubleGets the calculated main hand damage of this item stack.Gets the configured legacy display name of this custom item.intGets the current custom durability value.getId()Gets the id of this custom item without namespace.static @Nullable CustomStackgetInstance(String namespacedID) Gets a clone of the custom stack declared in ItemsAdder registry.Gets the Bukkit item stack handled by this wrapper.intGets the maximum custom durability value.Gets the model path configured for this custom item.Gets the namespace of this custom item.Gets the full namespaced id of this custom item.Gets all custom item namespaced ids currently registered.@Nullable StringGets the permission suffix configured for this custom item.getRequiredStats(ItemStack customItemStack) Gets the player stats required by a custom item stack.Gets the texture paths configured for this custom item.intGets the remaining usages stored on this item stack.booleanChecks if this custom item uses an automatically generated model.static booleanhasCooldown(Player player, ItemStack customItemStack) Checks if a player still has cooldown for a custom item stack.booleanChecks if this item stack uses ItemsAdder custom durability.booleanChecks if this custom item has a permission configured.booleanChecks if this item stack has the usages NBT attribute.booleanisBlock()Checks if this custom item is a custom block.static booleanChecks if an item stack is a custom block item.booleanChecks if this custom item blocks all enchantments.static booleanisComplexFurniture(ItemStack itemStack) Checks if an item stack is complex furniture.static booleanisFurniture(ItemStack itemStack) Checks if an item stack is furniture.static booleanisFurnitureConsumable(ItemStack itemStack) Checks if an item stack is consumable furniture.static booleanisFurnitureSittable(ItemStack itemStack) Checks if an item stack is sittable furniture.static booleanisFurnitureTradeMachine(ItemStack itemStack) Checks if an item stack is a furniture trade machine.static booleanisInRegistry(String namespacedId) Checks if a custom item is registered.static booleanChecks if an item stack is a vehicle.net.kyori.adventure.text.ComponentitemName()Gets the Adventure item name component from this item stack.booleanmatchNamespacedID(CustomStack other) Checks if another custom stack has the same namespaced id.static booleanopenTradeMenu(String namespacedId, Player player) Opens a furniture trade machine menu for a player.voidreduceUsages(int amount) Reduces the remaining usages stored on this item stack.static booleanrequiresStats(ItemStack customItemStack) Checks if a custom item stack requires player stats.voidsetAttributeModifier(String attributeModifier, String slotStr, double value) Complete list here: https://minecraft.gamepedia.com/Attribute#Attributes The slot can be mainhand, offhand, head, chest, legs or feet.voidsetDisplayName(String displayName) Deprecated.use Adventure item name APIs when possible.voidsetDurability(int durability) Sets the current custom durability value.voidsetMaxDurability(int maxDurability) Sets the maximum custom durability value.voidsetUsages(int amount) Sets the remaining usages stored on this item stack.voidupdateAttackDamageLore(String slot) Use this if you change attack damage of the item (via enchant or attribute modifier)voidupdateAttackSpeedLore(String slot) Use this if you change attack speed of the item
-
Constructor Details
-
CustomStack
public CustomStack()
-
-
Method Details
-
getNamespacedIdsInRegistry
-
isInRegistry
Checks if a custom item is registered.- Parameters:
namespacedId- the custom item namespaced id.- Returns:
- true if the custom item exists in the registry.
-
byItemStack
Returns null if the provided ItemStack is not a custom item created with ItemsAdder -
getInstance
Gets a clone of the custom stack declared in ItemsAdder registry. You can give this to a player and do whatever you want without overwriting the original item. -
getItemStack
Gets the Bukkit item stack handled by this wrapper.- Returns:
- the Bukkit item stack.
-
getNamespace
-
getId
-
getNamespacedID
Gets the full namespaced id of this custom item.- Returns:
- the namespaced id.
-
getModelPath
Gets the model path configured for this custom item.- Returns:
- the model path.
-
getConfigPath
Gets the configuration file path that defines this custom item.- Returns:
- the configuration file path.
-
getConfig
Gets the configuration file that defines this custom item.- Returns:
- the configuration file.
-
getPermission
Gets the permission suffix configured for this custom item.- Returns:
- the permission suffix, or null if no permission is configured.
-
hasPermission
public boolean hasPermission()Checks if this custom item has a permission configured.- Returns:
- true if a permission is configured.
-
matchNamespacedID
Checks if another custom stack has the same namespaced id.- Parameters:
other- the other custom stack.- Returns:
- true if both wrappers refer to the same custom item.
-
hasAutoGeneratedModel
public boolean hasAutoGeneratedModel()Checks if this custom item uses an automatically generated model.- Returns:
- true if the model is generated by ItemsAdder.
-
getTextures
-
isBlockAllEnchants
public boolean isBlockAllEnchants()Checks if this custom item blocks all enchantments.- Returns:
- true if all enchantments are blocked.
-
hasUsagesAttribute
public boolean hasUsagesAttribute()Checks if this item stack has the usages NBT attribute.- Returns:
- true if usages are stored on the item.
-
setUsages
public void setUsages(int amount) Sets the remaining usages stored on this item stack.- Parameters:
amount- the new usages amount.
-
reduceUsages
public void reduceUsages(int amount) Reduces the remaining usages stored on this item stack.- Parameters:
amount- the amount to subtract.
-
getUsages
public int getUsages()Gets the remaining usages stored on this item stack.- Returns:
- the usages amount.
-
hasCustomDurability
public boolean hasCustomDurability()Checks if this item stack uses ItemsAdder custom durability.- Returns:
- true if custom durability is enabled.
-
getDurability
public int getDurability()Gets the current custom durability value.- Returns:
- the current durability.
-
setDurability
public void setDurability(int durability) Sets the current custom durability value.- Parameters:
durability- the new durability.
-
getMaxDurability
public int getMaxDurability()Gets the maximum custom durability value.- Returns:
- the maximum durability.
-
setMaxDurability
public void setMaxDurability(int maxDurability) Sets the maximum custom durability value.- Parameters:
maxDurability- the new maximum durability.
-
setAttributeModifier
Complete list here: https://minecraft.gamepedia.com/Attribute#Attributes The slot can be mainhand, offhand, head, chest, legs or feet.Example: item.setAttributeModifier("attack_damage", "mainhand", 10d);
- Parameters:
attributeModifier-slotStr-value-
-
setDisplayName
Deprecated.use Adventure item name APIs when possible.Sets the legacy display name of this item stack.- Parameters:
displayName- the new display name.
-
getDisplayName
Gets the configured legacy display name of this custom item.- Returns:
- the legacy display name.
-
itemName
public net.kyori.adventure.text.Component itemName()Gets the Adventure item name component from this item stack.- Returns:
- the item name component, or null if no item name is stored.
-
getDamageMainhand
public double getDamageMainhand()Gets the calculated main hand damage of this item stack.- Returns:
- the main hand damage.
-
updateAttackDamageLore
Use this if you change attack damage of the item (via enchant or attribute modifier)- Parameters:
slot-
-
updateAttackSpeedLore
Use this if you change attack speed of the itemWARNING: it just appends at the end of the lore, no checking about already existing value.
- Parameters:
slot-
-
isBlock
public boolean isBlock()Checks if this custom item is a custom block.- Returns:
- true if this item is a custom block.
-
drop
Drops this item stack naturally at a location.- Parameters:
loc- the drop location.- Returns:
- true if the item was dropped.
-
getConfigSectionCopy
Gets a copy of this custom item's merged configuration section.- Returns:
- the copied configuration section.
-
getConfigSectionCopy
Gets a copy of this custom item's configuration section.- Parameters:
merged- true to include inherited and merged settings.- Returns:
- the copied configuration section.
-
hasCooldown
-
getCooldownMs
-
requiresStats
Checks if a custom item stack requires player stats.- Parameters:
customItemStack- the custom item stack.- Returns:
- true if the item has required stats.
-
getRequiredStats
-
openTradeMenu
-
isBlock
Checks if an item stack is a custom block item.- Parameters:
itemStack- the item stack to check.- Returns:
- true if the item is a custom block.
-
isFurniture
Checks if an item stack is furniture.- Parameters:
itemStack- the item stack to check.- Returns:
- true if the item has furniture behaviour.
-
isFurnitureConsumable
Checks if an item stack is consumable furniture.- Parameters:
itemStack- the item stack to check.- Returns:
- true if the item has consumable furniture behaviour.
-
isFurnitureTradeMachine
Checks if an item stack is a furniture trade machine.- Parameters:
itemStack- the item stack to check.- Returns:
- true if the item has trade machine furniture behaviour.
-
isFurnitureSittable
Checks if an item stack is sittable furniture.- Parameters:
itemStack- the item stack to check.- Returns:
- true if the item has sittable furniture behaviour.
-
isComplexFurniture
Checks if an item stack is complex furniture.- Parameters:
itemStack- the item stack to check.- Returns:
- true if the item has complex furniture behaviour.
-
isVehicle
Checks if an item stack is a vehicle.- Parameters:
itemStack- the item stack to check.- Returns:
- true if the item has vehicle behaviour.
-
getConfigSectionCopy
public static ConfigurationSection getConfigSectionCopy(ItemStack itemStack) throws IllegalStateException Gets a copy of the merged configuration section for a custom item stack.- Parameters:
itemStack- the custom item stack.- Returns:
- the copied configuration section, or null if the item is not custom.
- Throws:
IllegalStateException- if the configuration cannot be read.
-
getConfigSectionCopy
public static ConfigurationSection getConfigSectionCopy(ItemStack itemStack, boolean merged) throws IllegalStateException Gets a copy of the configuration section for a custom item stack.- Parameters:
itemStack- the custom item stack.merged- true to include inherited and merged settings.- Returns:
- the copied configuration section, or null if the item is not custom.
- Throws:
IllegalStateException- if the configuration cannot be read.
-