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 T
addLoreLines
(@NotNull String... 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.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.addLoreLines
(@NotNull List<@NotNull String> 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.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.default @NotNull ItemStack
build()
Compiles the patches, applying them on top of the prototype.@NotNull ItemStack
Compiles the patches, applying them on top of the prototype.@NotNull ItemBuilder
clone()
default @NotNull ItemBuilder
cloneWithNewPrototype
(@NotNull com.cryptomorin.xseries.XMaterial newPrototype) default @NotNull ItemBuilder
cloneWithNewPrototype
(@NotNull Material newPrototype) @NotNull ItemBuilder
cloneWithNewPrototype
(@NotNull ItemStack newPrototype) Create a clone of this builder with all the same patches, but a different prototypeItemStack
.default T
Alias ofremoveGlow()
.int
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.int
Get the damage of a damageable item, or 0 if not damageable / undamaged.
NOTE: This will always return 0 ifwillUseDamage()
returns false.int
getEnchantmentLevel
(@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()
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 @NotNull com.cryptomorin.xseries.XMaterial
Get theXMaterial
of the prototype item this builder is based on.
This is a convenience method, equivalent to callingXMaterial.matchXMaterial(ItemStack)
on the prototype.@Nullable String
getName()
Get the custom display name for the item.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.
If the patch name is null (not set), the prototype's name will be returned (if available).@NotNull ItemStack
@Nullable String
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.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.boolean
hasItemFlag
(@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 T
PATCH FUNCTION HELPER - Convenience method to hide common item attributes by adding multiple item flags.
This method adds the followingXItemFlag
s 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 boolean
Alias ofhasGlow()
.boolean
Get if the item is unbreakable or not.
If the patch unbreakable is null (not set), the prototype's unbreakable value will be returned.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 T
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.default T
replaceBoth
(@NotNull String find, @NotNull String replacement) 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.default T
Alias ofreplaceBothPAPI(OfflinePlayer)
with anull
player.default T
replaceBothPAPI
(@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 String replacement) 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.replaceLoreLine
(@NotNull String find, @NotNull List<@NotNull String> replacement) 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.
UsesChatColor.stripColor(String)
for comparison to ignore color formatting.default T
Alias ofreplaceLorePAPI(OfflinePlayer)
with anull
player.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 String replacement) 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.default T
Alias ofreplaceNamePAPI(OfflinePlayer)
with anull
player.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 T
setDisplayName
(@NotNull String name) Alias ofsetName(String)
.default T
setDurability
(int dur) Deprecated.default T
setDurability
(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 T
setGlow
(boolean glow) PATCH FUNCTION - Toggle the glow effect patch on or off.
default T
setItemFlag
(@NotNull com.cryptomorin.xseries.XItemFlag flag, boolean present) PATCH FUNCTION - Sets the presence of an item flag on the item.
PATCH FUNCTION - Sets the custom lore for the item.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.
Clear this patch by callingresetLore()
.PATCH FUNCTION - Sets the custom lore for the item.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.
Clear this patch by callingresetLore()
.PATCH FUNCTION - Applies a custom display name for the item.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.
Clear this patch by callingresetName()
.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 ItemStack
Alias ofbuild()
.default @NotNull ItemStack
toItemStack
(@Nullable Player player) Alias ofbuild(Player)
.boolean
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.boolean
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.
-
Method Details
-
getPrototype
Get the prototypeItemStack
this 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
ItemStack
this builder is based on.
-
getMaterial
@NotNull default @NotNull com.cryptomorin.xseries.XMaterial getMaterial()Get theXMaterial
of the prototype item this builder is based on.
This is a convenience method, equivalent to callingXMaterial.matchXMaterial(ItemStack)
on the prototype.- Returns:
- The
XMaterial
of 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
PATCH FUNCTION - Applies a custom display name for the item.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.
Clear this patch by callingresetName()
.- Returns:
- This builder, for chaining
-
setDisplayName
Alias ofsetName(String)
. -
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
PATCH FUNCTION - Sets the custom lore for the item.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.
Clear this patch by callingresetLore()
.- Returns:
- This builder, for chaining
-
setLore
PATCH FUNCTION - Sets the custom lore for the item.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.
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
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.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.- Parameters:
lines
- The lore lines to append- Returns:
- This builder, for chaining
-
addLoreLines
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.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.- 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 followingXItemFlag
s 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
Get the custom display name for the item.
Color translations usingStringUtilP.p(OfflinePlayer, String)
will be applied duringbuild(Player)
automatically.
If the patch name is null (not set), the prototype's name will be returned (if available). -
getLore
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
ItemStack
with all patches applied.
-
build
Compiles the patches, applying them on top of the prototype. -
toItemStack
Alias ofbuild()
.- Returns:
- The final
ItemStack
with all patches applied.
-
toItemStack
Alias ofbuild(Player)
. -
replaceName
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
-
replaceNamePAPI
Alias ofreplaceNamePAPI(OfflinePlayer)
with anull
player. -
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
@NotNull T replaceLoreLine(@NotNull @NotNull String find, @NotNull @NotNull List<@NotNull String> replacement) 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.
UsesChatColor.stripColor(String)
for comparison to ignore color formatting.- Parameters:
find
- The string to search for in the lore (color codes will be stripped for comparison)replacement
- The lines to swap in, in place of the entire line containing the find string- Returns:
- This builder, for chaining
-
replaceLore
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
-
replaceLorePAPI
Alias ofreplaceLorePAPI(OfflinePlayer)
with anull
player. -
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
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
-
replaceBothPAPI
Alias ofreplaceBothPAPI(OfflinePlayer)
with anull
player. -
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 theXMaterial
to 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 theMaterial
to anXMaterial
,
then usesXMaterial.parseItem()
to convert that to anItemStack
.- Since:
- 5.0.0-alpha.17
-
setDamage(int)
.