Package com.kamikazejam.kamicommon.item
Interface IBuilder<T extends IBuilder<T>>
- All Superinterfaces:
Cloneable
- All Known Implementing Classes:
ItemBuilder
-
Method Summary
Modifier and TypeMethodDescriptionaddGlow()PATCH FUNCTION - Sets whether the item should have an added glow effect.
Clear this patch by callingremoveGlow().addItemFlag(@NotNull com.cryptomorin.xseries.XItemFlag flag) addItemFlags(@NotNull Collection<com.cryptomorin.xseries.XItemFlag> flags) PATCH FUNCTION - Adds several item flags to the item.
Remove an item flag viaremoveItemFlag(XItemFlag).default TaddLoreComponents(@NotNull VersionedComponent... lines) PATCH FUNCTION - Appends additional lines to the current lore.
If no lore patch is currently set, this will create a new lore patch with the provided lines.
If a lore patch is already set, the new lines will be added to the end of the existing lore.
Colors are assumed to be already handled in the components.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).addLoreComponents(@NotNull List<@NotNull VersionedComponent> lines) PATCH FUNCTION - Appends additional lines to the current lore.
If no lore patch is currently set, this will create a new lore patch with the provided lines.
If a lore patch is already set, the new lines will be added to the end of the existing lore.
Colors are assumed to be already handled in the components.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).default TaddLoreLines(@NotNull String... lines) Deprecated.default TaddLoreLines(@NotNull List<@NotNull String> lines) Deprecated.As of 5.0.0-alpha.26, replaced byaddLoreComponents(List)default @NotNull ItemStackbuild()Compiles the patches, applying them on top of the prototype.@NotNull ItemStackCompiles the patches, applying them on top of the prototype.@NotNull ItemBuilderclone()default @NotNull ItemBuildercloneWithNewPrototype(@NotNull com.cryptomorin.xseries.XMaterial newPrototype) default @NotNull ItemBuildercloneWithNewPrototype(@NotNull Material newPrototype) @NotNull ItemBuildercloneWithNewPrototype(@NotNull ItemStack newPrototype) Create a clone of this builder with all the same patches, but a different prototypeItemStack.@Nullable VersionedComponentGet the custom display name for the item.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
If the patch name is null (not set), the prototype's name will be returned (if available).default TAlias ofremoveGlow().default @Nullable VersionedComponentGet the custom display name for the item.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
If the patch name is null (not set), the prototype's name will be returned (if available).displayName(@NotNull VersionedComponent name) PATCH FUNCTION - Applies a custom display name for the item.
Colors are assumed to be already handled in the component.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
Clear this patch by callingresetName().intGet the amount of items in the stack.
Range: 1 toItemStack.getMaxStackSize()(inclusive) of the prototype.
If the patch amount is null (not set), the prototype's amount is returned.intGet the damage of a damageable item, or 0 if not damageable / undamaged.
NOTE: This will always return 0 ifwillUseDamage()returns false.intgetEnchantmentLevel(@NotNull com.cryptomorin.xseries.XEnchantment enchant) Get the level of an enchantment on the item, or 0 if the item does not have this enchantment.
If the patch does not specify a level for this enchantment, the prototype's value will be returned.Get a map of ALL enchantments on the item.
This is the combination of the prototype's enchantments and the patch enchantment overrides.
This map is never null, but can be empty if no enchantments are present on the prototype or patch.@NotNull Set<com.cryptomorin.xseries.XItemFlag> Get a set of ALL item flags on the item.
This is the combination of the prototype's item flags and the patch item flag overrides.
This set is never null, but can be empty if no item flags are present on the prototype or patch.getLore()Deprecated.As of 5.0.0-alpha.26, replaced bylore()which returns components.default @NotNull com.cryptomorin.xseries.XMaterialGet theXMaterialof the prototype item this builder is based on.
This is a convenience method, equivalent to callingXMaterial.matchXMaterial(ItemStack)on the prototype.default @Nullable StringgetName()Deprecated.As of 5.0.0-alpha.26, replaced bydisplayName()which returns a component.@NotNull ItemStack@Nullable StringGet the owner of a player head item, or null if not set / not a player head.
NOTE: This will always return null ifwillUseSkullOwner()returns false.booleanhasGlow()Get if the item has an added glow effect.
If the patch glow is null (not set), the prototype's glow value will be returned.booleanhasItemFlag(@NotNull com.cryptomorin.xseries.XItemFlag flag) Get if the item has the specified item flag.
If the patch does not specify the presence of this flag, the prototype's value will be returned.default TPATCH FUNCTION HELPER - Convenience method to hide common item attributes by adding multiple item flags.
This method adds the followingXItemFlags to the item:
-XItemFlag.HIDE_ATTRIBUTES
-XItemFlag.HIDE_ENCHANTS
-XItemFlag.HIDE_PLACED_ON
-XItemFlag.HIDE_UNBREAKABLE
-XItemFlag.HIDE_ADDITIONAL_TOOLTIP
This is equivalent to callingaddItemFlag(XItemFlag)for each of the above flags.default booleanAlias ofhasGlow().booleanGet if the item is unbreakable or not.
If the patch unbreakable is null (not set), the prototype's unbreakable value will be returned.@Nullable List<@NotNull VersionedComponent> lore()Get the custom lore for the item.
If the patch lore is null (not set), the prototype's lore will be returned (if available).default Tlore(@NotNull VersionedComponent... lines) PATCH FUNCTION - Sets the custom lore for the item.
Colors are assumed to be already handled in the components.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
Clear this patch by callingresetLore().lore(@NotNull List<@NotNull VersionedComponent> lines) PATCH FUNCTION - Sets the custom lore for the item.
Colors are assumed to be already handled in the components.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
Clear this patch by callingresetLore().removeEnchantment(@NotNull com.cryptomorin.xseries.XEnchantment enchant) PATCH FUNCTION - Remove an enchantment from the item.
Other Methods:
- ADD or UPDATE an enchantment viasetEnchantment(XEnchantment, int)
- RESET an enchantment (remove patch) viaresetEnchantment(XEnchantment)PATCH FUNCTION - Removes the glow effect patch, the Builder will then use the prototype's value.
NOTE: The prototype's glow value is now used by the builder, this only removes any existing glow patch.
NOTE: Even when the glow patch is removed, the item may still glow if the prototype has enchantments or a glow effect.removeItemFlag(@NotNull com.cryptomorin.xseries.XItemFlag flag) removeItemFlags(@NotNull Collection<com.cryptomorin.xseries.XItemFlag> flags) PATCH FUNCTION - Removes several item flags from the item.
Add an item flag viaaddItemFlag(XItemFlag).default TPATCH FUNCTION - Sets the lore to an empty list, effectively removing all lore from the item.
This is equivalent to callingsetLore(List)with an empty list.
This differs fromresetLore()which clears the patch and uses the prototype's lore.default TreplaceBoth(@NotNull String find, @NotNull VersionedComponent replacement) PATCH PROPERTY HELPER - Convenience method to replace a substring in both name and lore.
This is equivalent to callingreplaceName(String, VersionedComponent)followed byreplaceLore(String, VersionedComponent).
This transformation only applies to existing patches, if no name or lore patches are set those won't be affected.
It does NOT modify the prototype's name or lore.default TreplaceBoth(@NotNull String find, @NotNull String replacement) Deprecated.As of 5.0.0-alpha.26, replaced byreplaceBoth(String, VersionedComponent)which supports components.default TAlias ofreplaceBothPAPI(OfflinePlayer)with anullplayer.default TreplaceBothPAPI(@Nullable OfflinePlayer player) PATCH PROPERTY HELPER - Convenience method to replace PlaceholderAPI placeholders in both name and lore.
This is equivalent to callingreplaceNamePAPI(OfflinePlayer)followed byreplaceLorePAPI(OfflinePlayer).
This transformation only applies to existing patches, if no name or lore patches are set those won't be affected.
It does NOT modify the prototype's name or lore.replaceLore(@NotNull String find, @NotNull VersionedComponent replacement) PATCH PROPERTY HELPER - Replaces all occurrences of a substring in each lore line with another component.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.
It will serialize each lore line into mini message format, perform the replacement, then deserialize it back to a component.default TreplaceLore(@NotNull String find, @NotNull String replacement) Deprecated.As of 5.0.0-alpha.26, replaced byreplaceLore(String, VersionedComponent)which supports components.default TreplaceLoreLine(@NotNull String find, @NotNull List<@NotNull String> replacements) Deprecated.As of 5.0.0-alpha.26, replaced byreplaceLoreLineComponent(String, List)which supports components.default TreplaceLoreLineComponent(@NotNull String find, @NotNull List<@NotNull VersionedComponent> replacements) PATCH PROPERTY HELPER - Searches for a substring in the lore and replaces that entire line with replacement lines.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.
For each line, it checks if the component plain text OR the component mini message contains the find string.
If either matches, that line is substituted with the replacement lines.replaceLoreLineComponent(@NotNull Predicate<@NotNull VersionedComponent> filter, @NotNull List<@NotNull VersionedComponent> replacements) PATCH PROPERTY HELPER - Replaces all occurrences of lines matching the given predicate in the lore with replacement lines.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.
For each line, it checks if the predicate returns true, and if so that line is replaced with the replacement lines.default TAlias ofreplaceLorePAPI(OfflinePlayer)with anullplayer.replaceLorePAPI(@Nullable OfflinePlayer player) PATCH PROPERTY HELPER - Replaces all PlaceholderAPI placeholders in the lore with their respective values.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.replaceName(@NotNull String find, @NotNull VersionedComponent replacement) PATCH PROPERTY HELPER - Replaces all occurrences of a substring in the name with another component.
This transformation only applies to the name patch, if no name patch is set this does nothing.
It does NOT modify the prototype's name.default TreplaceName(@NotNull String find, @NotNull String replacement) Deprecated.As of 5.0.0-alpha.26, replaced byreplaceName(String, VersionedComponent)which supports components.default TAlias ofreplaceNamePAPI(OfflinePlayer)with anullplayer.replaceNamePAPI(@Nullable OfflinePlayer player) PATCH PROPERTY HELPER - Replaces all PlaceholderAPI placeholders in the name with their respective values.
This transformation only applies to the name patch, if no name patch is set this does nothing.
It does NOT modify the prototype's name.PATCH FUNCTION - Clears all enchantment patches, the Builder will then use the prototype's values.
NOTE: The prototype's enchantments will still be applied, this only clears the patches.PATCH FUNCTION - Clears all item flag patches, the Builder will then use the prototype's values.
NOTE: The prototype's item flags will still be applied, this only clears the patches.PATCH FUNCTION - Clears the amount patch, the Builder will then use the prototype's value.
NOTE: The prototype's amount is now used by the builder, this only removes any existing amount patch.PATCH FUNCTION - Clears the damage patch, the Builder will then use the prototype's value.
NOTE: This function has no effect on the item unlesswillUseDamage()returns true, otherwise the item will be unaffected andgetDamage()will always return 0.
NOTE: The prototype's damage is now used by the builder (if applicable), this only removes any existing damage patch.resetEnchantment(@NotNull com.cryptomorin.xseries.XEnchantment enchant) PATCH FUNCTION - Reset an enchantment patch, the Builder will then use the prototype's value for this enchantment.
Other Methods:
- ADD or UPDATE an enchantment viasetEnchantment(XEnchantment, int)
- REMOVE an enchantment viaremoveEnchantment(XEnchantment)resetItemFlag(@NotNull com.cryptomorin.xseries.XItemFlag flag) PATCH FUNCTION - Resets an item flag patch, the Builder will then use the prototype's value for this flag.
Other Methods:
- ADD an item flag viaaddItemFlag(XItemFlag)
- REMOVE an item flag viaremoveItemFlag(XItemFlag)PATCH FUNCTION - Clears the lore patch, the Builder will then use the prototype's value.
NOTE: The prototype's lore is now used by the builder, this only removes any existing lore patch.PATCH FUNCTION - Clears the name patch, the Builder will then use the prototype's value.
NOTE: The prototype's name is now used by the builder, this only removes any existing name patch.PATCH FUNCTION - Clears the skull owner patch, the Builder will then use the prototype's value.
NOTE: This function has no effect on the item unlesswillUseSkullOwner()returns true, otherwise the item will be unaffected andgetSkullOwner()will always return null.
NOTE: The prototype's skull owner is now used by the builder (if applicable), this only removes any existing skull owner patch.PATCH FUNCTION - Clears the unbreakable patch, the Builder will then use the prototype's value.
NOTE: The prototype's unbreakable value is now used by the builder, this only removes any existing unbreakable patch.setAmount(int amount) PATCH FUNCTION - Sets the amount of items in the stack.
Range: 1 toItemStack.getMaxStackSize()(inclusive) of the prototype.
Clear this patch by callingresetAmount().setDamage(int damage) PATCH FUNCTION - Sets the damage of a damageable item.
NOTE: This function has no effect on the item unlesswillUseDamage()returns true, otherwise the item will be unaffected andgetDamage()will always return 0.
Clear this patch by callingresetDamage().default TsetDisplayName(@NotNull String name) Deprecated.As of 5.0.0-alpha.26, replaced bydisplayName(VersionedComponent).default TsetDurability(int dur) Deprecated.As of 5.0.0-alpha.17, replaced bysetDamage(int).default TsetDurability(short dur) Deprecated.As of 5.0.0-alpha.17, replaced bysetDamage(int).setEnchantment(@NotNull com.cryptomorin.xseries.XEnchantment enchant, int level) PATCH FUNCTION - Sets the level of an enchantment on the item.
Other Methods:
- REMOVE an enchantment viaremoveEnchantment(XEnchantment)
- RESET an enchantment (remove patch) viaresetEnchantment(XEnchantment)setEnchantments(@NotNull Map<com.cryptomorin.xseries.XEnchantment, Integer> enchantments) PATCH FUNCTION - Sets the level of several enchantments on the item.
Other Methods:
- REMOVE an enchantment viaremoveEnchantment(XEnchantment)
- RESET an enchantment (remove patch) viaresetEnchantment(XEnchantment)default TsetGlow(boolean glow) PATCH FUNCTION - Toggle the glow effect patch on or off.
default TsetItemFlag(@NotNull com.cryptomorin.xseries.XItemFlag flag, boolean present) PATCH FUNCTION - Sets the presence of an item flag on the item.
default TDeprecated.As of 5.0.0-alpha.26, replaced bylore(VersionedComponent...).default TDeprecated.As of 5.0.0-alpha.26, replaced bylore(List)default TDeprecated.As of 5.0.0-alpha.26, replaced bydisplayName(VersionedComponent).setSkullOwner(@NotNull String owner) PATCH FUNCTION - Sets the owner of a player head item.
NOTE: This function has no effect on the item unlesswillUseSkullOwner()returns true, otherwise the item will be unaffected andgetSkullOwner()will always return null.
Clear this patch by callingresetSkullOwner().setUnbreakable(boolean unbreakable) PATCH FUNCTION - Sets if the item is unbreakable or not.
Clear this patch by callingresetUnbreakable().default @NotNull ItemStackAlias ofbuild().default @NotNull ItemStacktoItemStack(@Nullable Player player) Alias ofbuild(Player).booleanCheck if the prototype item supports setting damage (is damageable).
If this returns true, then the following methods will modify the item:
-setDamage(int)
-resetDamage()
-getDamage()
If this returns false, calling those methods have no effect andgetDamage()will always return 0.booleanCheck if the prototype item supports setting a skull owner (is a player head).
If this returns true, then the following methods will modify the item:
-setSkullOwner(String)
-resetSkullOwner()
-getSkullOwner()
If this returns false, calling those methods have no effect andgetSkullOwner()will always return null.
-
Method Details
-
getPrototype
Get the prototypeItemStackthis builder is based on.
The prototype is never modified, it is immutable, and accessed via this method.
Usebuild()to get the final version of the item with all patches applied.- Returns:
- The prototype
ItemStackthis builder is based on.
-
getMaterial
@NotNull default @NotNull com.cryptomorin.xseries.XMaterial getMaterial()Get theXMaterialof the prototype item this builder is based on.
This is a convenience method, equivalent to callingXMaterial.matchXMaterial(ItemStack)on the prototype.- Returns:
- The
XMaterialof the prototype item this builder is based on.
-
setAmount
PATCH FUNCTION - Sets the amount of items in the stack.
Range: 1 toItemStack.getMaxStackSize()(inclusive) of the prototype.
Clear this patch by callingresetAmount().
(If the amount is out of range, it will be clamped within the valid range.)- Returns:
- This builder, for chaining
-
resetAmount
PATCH FUNCTION - Clears the amount patch, the Builder will then use the prototype's value.
NOTE: The prototype's amount is now used by the builder, this only removes any existing amount patch.- Returns:
- This builder, for chaining
-
setDamage
PATCH FUNCTION - Sets the damage of a damageable item.
NOTE: This function has no effect on the item unlesswillUseDamage()returns true, otherwise the item will be unaffected andgetDamage()will always return 0.
Clear this patch by callingresetDamage().- Parameters:
damage- The damage value to set (0 = undamaged)- Returns:
- This builder, for chaining
-
setDurability
Deprecated.As of 5.0.0-alpha.17, replaced bysetDamage(int).Alias ofsetDamage(int). -
setDurability
Deprecated.As of 5.0.0-alpha.17, replaced bysetDamage(int).Alias ofsetDamage(int). -
resetDamage
PATCH FUNCTION - Clears the damage patch, the Builder will then use the prototype's value.
NOTE: This function has no effect on the item unlesswillUseDamage()returns true, otherwise the item will be unaffected andgetDamage()will always return 0.
NOTE: The prototype's damage is now used by the builder (if applicable), this only removes any existing damage patch.- Returns:
- This builder, for chaining
-
setName
Deprecated.As of 5.0.0-alpha.26, replaced bydisplayName(VersionedComponent).Alias ofsetDisplayName(String).- Returns:
- This builder, for chaining
-
setDisplayName
Deprecated.As of 5.0.0-alpha.26, replaced bydisplayName(VersionedComponent).PATCH FUNCTION - Applies a custom display name for the item.
Colors are translated automatically viaLegacyColors.t(String).
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
Clear this patch by callingresetName().- Returns:
- This builder, for chaining
-
displayName
PATCH FUNCTION - Applies a custom display name for the item.
Colors are assumed to be already handled in the component.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
Clear this patch by callingresetName().- Returns:
- This builder, for chaining
-
resetName
PATCH FUNCTION - Clears the name patch, the Builder will then use the prototype's value.
NOTE: The prototype's name is now used by the builder, this only removes any existing name patch.- Returns:
- This builder, for chaining
-
setLore
Deprecated.As of 5.0.0-alpha.26, replaced bylore(VersionedComponent...).PATCH FUNCTION - Sets the custom lore for the item.
Colors are translated automatically viaLegacyColors.t(String).
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
Clear this patch by callingresetLore().- Returns:
- This builder, for chaining
-
setLore
Deprecated.As of 5.0.0-alpha.26, replaced bylore(List)PATCH FUNCTION - Sets the custom lore for the item.
Colors are translated automatically viaLegacyColors.t(String).
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
Clear this patch by callingresetLore().- Returns:
- This builder, for chaining
-
lore
PATCH FUNCTION - Sets the custom lore for the item.
Colors are assumed to be already handled in the components.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
Clear this patch by callingresetLore().- Returns:
- This builder, for chaining
-
lore
PATCH FUNCTION - Sets the custom lore for the item.
Colors are assumed to be already handled in the components.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
Clear this patch by callingresetLore().- Returns:
- This builder, for chaining
-
resetLore
PATCH FUNCTION - Clears the lore patch, the Builder will then use the prototype's value.
NOTE: The prototype's lore is now used by the builder, this only removes any existing lore patch.- Returns:
- This builder, for chaining
-
removeLore
PATCH FUNCTION - Sets the lore to an empty list, effectively removing all lore from the item.
This is equivalent to callingsetLore(List)with an empty list.
This differs fromresetLore()which clears the patch and uses the prototype's lore.- Returns:
- This builder, for chaining
-
addLoreLines
Deprecated.As of 5.0.0-alpha.26, replaced byaddLoreComponents(List)PATCH FUNCTION - Appends additional lines to the current lore.
If no lore patch is currently set, this will create a new lore patch with the provided lines.
If a lore patch is already set, the new lines will be added to the end of the existing lore.
Colors are translated automatically viaLegacyColors.t(String).
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).- Parameters:
lines- The lore lines to append- Returns:
- This builder, for chaining
-
addLoreLines
Deprecated.As of 5.0.0-alpha.26, replaced byaddLoreComponents(VersionedComponent...)PATCH FUNCTION - Appends additional lines to the current lore.
If no lore patch is currently set, this will create a new lore patch with the provided lines.
If a lore patch is already set, the new lines will be added to the end of the existing lore.
Colors are translated automatically viaLegacyColors.t(String).
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).- Parameters:
lines- The lore lines to append- Returns:
- This builder, for chaining
-
addLoreComponents
PATCH FUNCTION - Appends additional lines to the current lore.
If no lore patch is currently set, this will create a new lore patch with the provided lines.
If a lore patch is already set, the new lines will be added to the end of the existing lore.
Colors are assumed to be already handled in the components.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).- Parameters:
lines- The lore lines to append- Returns:
- This builder, for chaining
-
addLoreComponents
PATCH FUNCTION - Appends additional lines to the current lore.
If no lore patch is currently set, this will create a new lore patch with the provided lines.
If a lore patch is already set, the new lines will be added to the end of the existing lore.
Colors are assumed to be already handled in the components.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).- Parameters:
lines- The lore lines to append- Returns:
- This builder, for chaining
-
setUnbreakable
PATCH FUNCTION - Sets if the item is unbreakable or not.
Clear this patch by callingresetUnbreakable().- Returns:
- This builder, for chaining
-
resetUnbreakable
PATCH FUNCTION - Clears the unbreakable patch, the Builder will then use the prototype's value.
NOTE: The prototype's unbreakable value is now used by the builder, this only removes any existing unbreakable patch.- Returns:
- This builder, for chaining
-
addItemFlag
- Returns:
- This builder, for chaining
-
addItemFlags
PATCH FUNCTION - Adds several item flags to the item.
Remove an item flag viaremoveItemFlag(XItemFlag).- Returns:
- This builder, for chaining
-
removeItemFlag
- Returns:
- This builder, for chaining
-
removeItemFlags
PATCH FUNCTION - Removes several item flags from the item.
Add an item flag viaaddItemFlag(XItemFlag).- Returns:
- This builder, for chaining
-
setItemFlag
@NotNull default T setItemFlag(@NotNull @NotNull com.cryptomorin.xseries.XItemFlag flag, boolean present) PATCH FUNCTION - Sets the presence of an item flag on the item.
- Parameters:
present- If true, the flag will be added, if false it will be removed.- Returns:
- This builder, for chaining
-
resetItemFlag
PATCH FUNCTION - Resets an item flag patch, the Builder will then use the prototype's value for this flag.
Other Methods:
- ADD an item flag viaaddItemFlag(XItemFlag)
- REMOVE an item flag viaremoveItemFlag(XItemFlag)- Returns:
- This builder, for chaining
-
resetAllItemFlags
PATCH FUNCTION - Clears all item flag patches, the Builder will then use the prototype's values.
NOTE: The prototype's item flags will still be applied, this only clears the patches. -
hideAttributes
PATCH FUNCTION HELPER - Convenience method to hide common item attributes by adding multiple item flags.
This method adds the followingXItemFlags to the item:
-XItemFlag.HIDE_ATTRIBUTES
-XItemFlag.HIDE_ENCHANTS
-XItemFlag.HIDE_PLACED_ON
-XItemFlag.HIDE_UNBREAKABLE
-XItemFlag.HIDE_ADDITIONAL_TOOLTIP
This is equivalent to callingaddItemFlag(XItemFlag)for each of the above flags.- Returns:
- This builder, for chaining
-
setEnchantment
@NotNull T setEnchantment(@NotNull @NotNull com.cryptomorin.xseries.XEnchantment enchant, int level) PATCH FUNCTION - Sets the level of an enchantment on the item.
Other Methods:
- REMOVE an enchantment viaremoveEnchantment(XEnchantment)
- RESET an enchantment (remove patch) viaresetEnchantment(XEnchantment)- Parameters:
level- The level of the enchantment to set (MUST be greater than 0)- Returns:
- This builder, for chaining
-
setEnchantments
@NotNull T setEnchantments(@NotNull @NotNull Map<com.cryptomorin.xseries.XEnchantment, Integer> enchantments) PATCH FUNCTION - Sets the level of several enchantments on the item.
Other Methods:
- REMOVE an enchantment viaremoveEnchantment(XEnchantment)
- RESET an enchantment (remove patch) viaresetEnchantment(XEnchantment)- Parameters:
enchantments- The map of enchantments to their levels to set (all levels MUST be greater than 0)- Returns:
- This builder, for chaining
-
removeEnchantment
PATCH FUNCTION - Remove an enchantment from the item.
Other Methods:
- ADD or UPDATE an enchantment viasetEnchantment(XEnchantment, int)
- RESET an enchantment (remove patch) viaresetEnchantment(XEnchantment)- Returns:
- This builder, for chaining
-
resetEnchantment
PATCH FUNCTION - Reset an enchantment patch, the Builder will then use the prototype's value for this enchantment.
Other Methods:
- ADD or UPDATE an enchantment viasetEnchantment(XEnchantment, int)
- REMOVE an enchantment viaremoveEnchantment(XEnchantment)- Returns:
- This builder, for chaining
-
resetAllEnchantments
PATCH FUNCTION - Clears all enchantment patches, the Builder will then use the prototype's values.
NOTE: The prototype's enchantments will still be applied, this only clears the patches.- Returns:
- This builder, for chaining
-
addGlow
PATCH FUNCTION - Sets whether the item should have an added glow effect.
Clear this patch by callingremoveGlow().- Returns:
- This builder, for chaining
-
removeGlow
PATCH FUNCTION - Removes the glow effect patch, the Builder will then use the prototype's value.
NOTE: The prototype's glow value is now used by the builder, this only removes any existing glow patch.
NOTE: Even when the glow patch is removed, the item may still glow if the prototype has enchantments or a glow effect.- Returns:
- This builder, for chaining
-
disableGlow
Alias ofremoveGlow(). -
setGlow
PATCH FUNCTION - Toggle the glow effect patch on or off.
- Parameters:
glow- If true, the glow effect patch will be added, if false it will be removed.- Returns:
- This builder, for chaining
-
setSkullOwner
PATCH FUNCTION - Sets the owner of a player head item.
NOTE: This function has no effect on the item unlesswillUseSkullOwner()returns true, otherwise the item will be unaffected andgetSkullOwner()will always return null.
Clear this patch by callingresetSkullOwner().- Returns:
- This builder, for chaining
-
resetSkullOwner
PATCH FUNCTION - Clears the skull owner patch, the Builder will then use the prototype's value.
NOTE: This function has no effect on the item unlesswillUseSkullOwner()returns true, otherwise the item will be unaffected andgetSkullOwner()will always return null.
NOTE: The prototype's skull owner is now used by the builder (if applicable), this only removes any existing skull owner patch.- Returns:
- This builder, for chaining
-
getAmount
int getAmount()Get the amount of items in the stack.
Range: 1 toItemStack.getMaxStackSize()(inclusive) of the prototype.
If the patch amount is null (not set), the prototype's amount is returned. -
getDamage
int getDamage()Get the damage of a damageable item, or 0 if not damageable / undamaged.
NOTE: This will always return 0 ifwillUseDamage()returns false. -
willUseDamage
boolean willUseDamage()Check if the prototype item supports setting damage (is damageable).
If this returns true, then the following methods will modify the item:
-setDamage(int)
-resetDamage()
-getDamage()
If this returns false, calling those methods have no effect andgetDamage()will always return 0. -
getName
Deprecated.As of 5.0.0-alpha.26, replaced bydisplayName()which returns a component.Get the custom display name for the item.
If the patch name is null (not set), the prototype's name will be returned (if available). -
displayName
Get the custom display name for the item.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
If the patch name is null (not set), the prototype's name will be returned (if available). -
customName
Get the custom display name for the item.
Placeholders are set automatically viaSoftPlaceholderAPI.setPlaceholders(OfflinePlayer, String).
If the patch name is null (not set), the prototype's name will be returned (if available). -
getLore
Deprecated.As of 5.0.0-alpha.26, replaced bylore()which returns components.Get the custom lore for the item.
If the patch lore is null (not set), the prototype's lore will be returned (if available). -
lore
Get the custom lore for the item.
If the patch lore is null (not set), the prototype's lore will be returned (if available). -
isUnbreakable
boolean isUnbreakable()Get if the item is unbreakable or not.
If the patch unbreakable is null (not set), the prototype's unbreakable value will be returned. -
hasItemFlag
boolean hasItemFlag(@NotNull @NotNull com.cryptomorin.xseries.XItemFlag flag) Get if the item has the specified item flag.
If the patch does not specify the presence of this flag, the prototype's value will be returned. -
getItemFlags
Get a set of ALL item flags on the item.
This is the combination of the prototype's item flags and the patch item flag overrides.
This set is never null, but can be empty if no item flags are present on the prototype or patch. -
getEnchantmentLevel
int getEnchantmentLevel(@NotNull @NotNull com.cryptomorin.xseries.XEnchantment enchant) Get the level of an enchantment on the item, or 0 if the item does not have this enchantment.
If the patch does not specify a level for this enchantment, the prototype's value will be returned. -
getEnchantments
Get a map of ALL enchantments on the item.
This is the combination of the prototype's enchantments and the patch enchantment overrides.
This map is never null, but can be empty if no enchantments are present on the prototype or patch. -
hasGlow
boolean hasGlow()Get if the item has an added glow effect.
If the patch glow is null (not set), the prototype's glow value will be returned. -
isAddGlow
default boolean isAddGlow()Alias ofhasGlow(). -
getSkullOwner
Get the owner of a player head item, or null if not set / not a player head.
NOTE: This will always return null ifwillUseSkullOwner()returns false. -
willUseSkullOwner
boolean willUseSkullOwner()Check if the prototype item supports setting a skull owner (is a player head).
If this returns true, then the following methods will modify the item:
-setSkullOwner(String)
-resetSkullOwner()
-getSkullOwner()
If this returns false, calling those methods have no effect andgetSkullOwner()will always return null. -
build
Compiles the patches, applying them on top of the prototype.- Returns:
- The final
ItemStackwith all patches applied.
-
build
Compiles the patches, applying them on top of the prototype. -
toItemStack
Alias ofbuild().- Returns:
- The final
ItemStackwith all patches applied.
-
toItemStack
Alias ofbuild(Player). -
replaceName
@Deprecated @NotNull default T replaceName(@NotNull @NotNull String find, @NotNull @NotNull String replacement) Deprecated.As of 5.0.0-alpha.26, replaced byreplaceName(String, VersionedComponent)which supports components.PATCH PROPERTY HELPER - Replaces all occurrences of a substring in the name with another string.
This transformation only applies to the name patch, if no name patch is set this does nothing.
It does NOT modify the prototype's name.- Parameters:
find- The substring to findreplacement- The sub- Returns:
- This builder, for chaining
-
replaceName
@NotNull T replaceName(@NotNull @NotNull String find, @NotNull @NotNull VersionedComponent replacement) PATCH PROPERTY HELPER - Replaces all occurrences of a substring in the name with another component.
This transformation only applies to the name patch, if no name patch is set this does nothing.
It does NOT modify the prototype's name.
It will serialize the name into message format, perform the replacement, then deserialize it back to a component.- Parameters:
find- The substring to findreplacement- The component to replace each occurrence with- Returns:
- This builder, for chaining
-
replaceNamePAPI
Alias ofreplaceNamePAPI(OfflinePlayer)with anullplayer. -
replaceNamePAPI
PATCH PROPERTY HELPER - Replaces all PlaceholderAPI placeholders in the name with their respective values.
This transformation only applies to the name patch, if no name patch is set this does nothing.
It does NOT modify the prototype's name.- Parameters:
player- The player to use for PlaceholderAPI replacements, or null to skip player-specific placeholders- Returns:
- This builder, for chaining
-
replaceLoreLine
@Deprecated @NotNull default T replaceLoreLine(@NotNull @NotNull String find, @NotNull @NotNull List<@NotNull String> replacements) Deprecated.As of 5.0.0-alpha.26, replaced byreplaceLoreLineComponent(String, List)which supports components.PATCH PROPERTY HELPER - Searches for a substring in the lore and replaces that entire line with replacement lines.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.
For each line, it checks if the component plain text OR the component mini message contains the find string.
If either matches, that line is substituted with the replacement lines.- Parameters:
find- The string to search for in the lore (color codes will be stripped for comparison)replacements- The lines to swap in, in place of the entire line containing the find string- Returns:
- This builder, for chaining
-
replaceLoreLineComponent
@NotNull default T replaceLoreLineComponent(@NotNull @NotNull String find, @NotNull @NotNull List<@NotNull VersionedComponent> replacements) PATCH PROPERTY HELPER - Searches for a substring in the lore and replaces that entire line with replacement lines.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.
For each line, it checks if the component plain text OR the component mini message contains the find string.
If either matches, that line is substituted with the replacement lines.- Parameters:
find- The string to search for in the lorereplacements- The lines to swap in, in place of the entire line containing the find string- Returns:
- This builder, for chaining
-
replaceLoreLineComponent
@NotNull T replaceLoreLineComponent(@NotNull @NotNull Predicate<@NotNull VersionedComponent> filter, @NotNull @NotNull List<@NotNull VersionedComponent> replacements) PATCH PROPERTY HELPER - Replaces all occurrences of lines matching the given predicate in the lore with replacement lines.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.
For each line, it checks if the predicate returns true, and if so that line is replaced with the replacement lines.- Parameters:
filter- The predicate to test each lore line against, if it returns true that line is replacedreplacements- The lines to swap in, in place of the entire line containing the find string- Returns:
- This builder, for chaining
-
replaceLore
@Deprecated @NotNull default T replaceLore(@NotNull @NotNull String find, @NotNull @NotNull String replacement) Deprecated.As of 5.0.0-alpha.26, replaced byreplaceLore(String, VersionedComponent)which supports components.PATCH PROPERTY HELPER - Replaces all occurrences of a substring in each lore line with another string.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.- Parameters:
find- The substring to find in each lore linereplacement- The string to replace each occurrence with- Returns:
- This builder, for chaining
-
replaceLore
PATCH PROPERTY HELPER - Replaces all occurrences of a substring in each lore line with another component.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.
It will serialize each lore line into mini message format, perform the replacement, then deserialize it back to a component.- Parameters:
find- The substring to find in each lore linereplacement- The component to replace each occurrence with- Returns:
- This builder, for chaining
-
replaceLorePAPI
Alias ofreplaceLorePAPI(OfflinePlayer)with anullplayer. -
replaceLorePAPI
PATCH PROPERTY HELPER - Replaces all PlaceholderAPI placeholders in the lore with their respective values.
This transformation only applies to the lore patch, if no lore patch is set this does nothing.
It does NOT modify the prototype's lore.- Parameters:
player- The player to use for PlaceholderAPI replacements, or null to skip player-specific placeholders- Returns:
- This builder, for chaining
-
replaceBoth
@Deprecated @NotNull default T replaceBoth(@NotNull @NotNull String find, @NotNull @NotNull String replacement) Deprecated.As of 5.0.0-alpha.26, replaced byreplaceBoth(String, VersionedComponent)which supports components.PATCH PROPERTY HELPER - Convenience method to replace a substring in both name and lore.
This is equivalent to callingreplaceName(String, String)followed byreplaceLore(String, String).
This transformation only applies to existing patches, if no name or lore patches are set those won't be affected.
It does NOT modify the prototype's name or lore.- Parameters:
find- The substring to find in name and lorereplacement- The string to replace each occurrence with- Returns:
- This builder, for chaining
-
replaceBoth
@NotNull default T replaceBoth(@NotNull @NotNull String find, @NotNull @NotNull VersionedComponent replacement) PATCH PROPERTY HELPER - Convenience method to replace a substring in both name and lore.
This is equivalent to callingreplaceName(String, VersionedComponent)followed byreplaceLore(String, VersionedComponent).
This transformation only applies to existing patches, if no name or lore patches are set those won't be affected.
It does NOT modify the prototype's name or lore.- Parameters:
find- The substring to find in name and lorereplacement- The component to replace each occurrence with- Returns:
- This builder, for chaining
-
replaceBothPAPI
Alias ofreplaceBothPAPI(OfflinePlayer)with anullplayer. -
replaceBothPAPI
PATCH PROPERTY HELPER - Convenience method to replace PlaceholderAPI placeholders in both name and lore.
This is equivalent to callingreplaceNamePAPI(OfflinePlayer)followed byreplaceLorePAPI(OfflinePlayer).
This transformation only applies to existing patches, if no name or lore patches are set those won't be affected.
It does NOT modify the prototype's name or lore.- Parameters:
player- The player to use for PlaceholderAPI replacements, or null to skip player-specific placeholders- Returns:
- This builder, for chaining
-
clone
-
cloneWithNewPrototype
Create a clone of this builder with all the same patches, but a different prototypeItemStack.- Since:
- 5.0.0-alpha.17
-
cloneWithNewPrototype
@NotNull default @NotNull ItemBuilder cloneWithNewPrototype(@NotNull @NotNull com.cryptomorin.xseries.XMaterial newPrototype) Create a clone of this builder with all the same patches, but a different prototypeItemStack.
This method usesXMaterial.parseItem()to convert theXMaterialto anItemStack.- Since:
- 5.0.0-alpha.17
-
cloneWithNewPrototype
@NotNull default @NotNull ItemBuilder cloneWithNewPrototype(@NotNull @NotNull Material newPrototype) Create a clone of this builder with all the same patches, but a different prototypeItemStack.
This method usesXMaterial.matchXMaterial(Material)to convert theMaterialto anXMaterial,
then usesXMaterial.parseItem()to convert that to anItemStack.- Since:
- 5.0.0-alpha.17
-
addLoreComponents(VersionedComponent...)