Class CustomItem.Builder
java.lang.Object
com.github.imdabigboss.easydatapack.api.items.CustomItem.Builder
- Direct Known Subclasses:
CustomHatItem.Builder,CustomToolItem.Builder
- Enclosing class:
- CustomItem
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<org.bukkit.enchantments.Enchantment>protected org.bukkit.Materialprotected intprotected Class<? extends org.bukkit.event.Listener>protected List<org.bukkit.enchantments.Enchantment>protected booleanprotected Consumer<org.bukkit.event.player.PlayerInteractEvent>protected String[]protected Stringprotected Stringprotected booleanprotected booleanprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull CustomItem.BuilderallowedEnchantment(@NonNull org.bukkit.enchantments.Enchantment... enchantments)Adds an allowed enchantment to the item, this can be used if the base material doesn't allow the enchantment by default.@NonNull CustomItem.BuilderattributeModifier(@NonNull org.bukkit.attribute.Attribute attribute, @NonNull org.bukkit.attribute.AttributeModifier attributeModifier)Adds an attribute modifier to the item.@NonNull CustomItembuild()Builds the item.@NonNull CustomItem.Builderenchantment(@NonNull org.bukkit.enchantments.Enchantment enchantment, int level)Adds an enchantment to the item.@NonNull CustomItem.BuildereventListener(@Nullable Class<? extends org.bukkit.event.Listener> eventListener)Sets the event listener of the item.@NonNull CustomItem.BuilderforbiddenEnchantment(@NonNull org.bukkit.enchantments.Enchantment... enchantments)Adds a forbidden enchantment to the item, this can be used if the base material allows the enchantment by default.@NonNull CustomItem.BuilderhideFlags(boolean hideFlags)Sets if the item hides flags.@NonNull CustomItem.BuilderitemUseEvent(@Nullable Consumer<org.bukkit.event.player.PlayerInteractEvent> itemUseEvent)Sets the event listener of the item.@NonNull CustomItem.BuilderSets the item lore.@NonNull CustomItem.BuilderSets the item lore.@NonNull CustomItem.BuildernewItem(boolean newItem)Sets if the item is a new item or if it is an extension of an existing item.@NonNull CustomItem.Builderunbreakable(boolean unbreakable)Sets if the item is unbreakable.
-
Field Details
-
customModelData
protected final int customModelData -
namespaceKey
-
name
-
baseMaterial
protected final org.bukkit.Material baseMaterial -
unbreakable
protected boolean unbreakable -
hideFlags
protected boolean hideFlags -
newItem
protected boolean newItem -
itemUseEvent
-
eventListener
-
spacingBeforeLore
protected boolean spacingBeforeLore -
lore
-
attributeModifiers
-
enchantments
-
allowedEnchantments
-
forbiddenEnchantments
-
-
Constructor Details
-
Builder
public Builder(int customModelData, String namespaceKey, String name, org.bukkit.Material baseMaterial)Creates a new item builder.- Parameters:
customModelData- the custom model data of the itemnamespaceKey- the namespace key of the itemname- the name of the itembaseMaterial- the base material of the item
-
-
Method Details
-
unbreakable
Sets if the item is unbreakable.- Parameters:
unbreakable- if the item is unbreakable- Returns:
- the builder
-
hideFlags
Sets if the item hides flags.- Parameters:
hideFlags- if the item hides flags- Returns:
- the builder
-
newItem
Sets if the item is a new item or if it is an extension of an existing item.- Parameters:
newItem- if the item is a new item- Returns:
- the builder
-
itemUseEvent
public @NonNull CustomItem.Builder itemUseEvent(@Nullable @Nullable Consumer<org.bukkit.event.player.PlayerInteractEvent> itemUseEvent)Sets the event listener of the item.- Parameters:
itemUseEvent- the event listener of the item- Returns:
- the builder
-
eventListener
public @NonNull CustomItem.Builder eventListener(@Nullable @Nullable Class<? extends org.bukkit.event.Listener> eventListener)Sets the event listener of the item.- Parameters:
eventListener- the event listener of the item- Returns:
- the builder
-
lore
Sets the item lore.- Parameters:
spacingBeforeLore- if there should be spacing before the lorelore- the lore- Returns:
- the builder
-
lore
Sets the item lore.- Parameters:
lore- the lore- Returns:
- the builder
-
attributeModifier
public @NonNull CustomItem.Builder attributeModifier(@NonNull org.bukkit.attribute.Attribute attribute, @NonNull org.bukkit.attribute.AttributeModifier attributeModifier)Adds an attribute modifier to the item.- Parameters:
attribute- the attributeattributeModifier- the attribute modifier- Returns:
- the builder
-
enchantment
public @NonNull CustomItem.Builder enchantment(@NonNull org.bukkit.enchantments.Enchantment enchantment, int level)Adds an enchantment to the item.- Parameters:
enchantment- the enchantmentlevel- the level- Returns:
- the builder
-
allowedEnchantment
public @NonNull CustomItem.Builder allowedEnchantment(@NonNull org.bukkit.enchantments.Enchantment... enchantments) throws CustomItemExceptionAdds an allowed enchantment to the item, this can be used if the base material doesn't allow the enchantment by default.- Parameters:
enchantments- the enchantments- Returns:
- the builder
- Throws:
CustomItemException
-
forbiddenEnchantment
public @NonNull CustomItem.Builder forbiddenEnchantment(@NonNull org.bukkit.enchantments.Enchantment... enchantments) throws CustomItemExceptionAdds a forbidden enchantment to the item, this can be used if the base material allows the enchantment by default.- Parameters:
enchantments- the enchantments- Returns:
- the builder
- Throws:
CustomItemException
-
build
Builds the item.- Returns:
- the item
-