Class CustomEnchantment.Builder
java.lang.Object
com.github.imdabigboss.easydatapack.api.enchantments.CustomEnchantment.Builder
- Enclosing class:
- CustomEnchantment
This class represents a builder for creating custom enchantments.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Predicate<org.bukkit.inventory.ItemStack>protected List<org.bukkit.enchantments.Enchantment>protected booleanprotected BiFunction<Integer,org.bukkit.entity.EntityCategory,Float>protected booleanprotected org.bukkit.enchantments.EnchantmentTargetprotected Class<? extends org.bukkit.event.Listener>protected intprotected Stringprotected Stringprotected io.papermc.paper.enchantments.EnchantmentRarityprotected intprotected booleanprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull CustomEnchantment.BuilderaddConflict(org.bukkit.enchantments.Enchantment... conflict)Adds a conflicting enchantment.@NonNull CustomEnchantment.BuilderanvilMergeCost(@NonNull Function<Integer,Integer> anvilMergeCost)Sets the anvil merge cost of the enchantment.@NonNull CustomEnchantmentbuild()Builds the enchantment.@NonNull CustomEnchantment.Buildercursed(boolean cursed)Sets if the enchantment is a curse.@NonNull CustomEnchantment.BuilderdamageIncrease(@NonNull BiFunction<Integer,org.bukkit.entity.EntityCategory,Float> damageIncrease)Sets the damage increase of the enchantment.@NonNull CustomEnchantment.Builderdiscoverable(boolean discoverable)Sets if the enchantment is discoverable.@NonNull CustomEnchantment.BuildereventListener(@Nullable Class<? extends org.bukkit.event.Listener> eventListener)Sets the event listener of the enchantment.@NonNull CustomEnchantment.BuildermaxLevel(int maxLevel)Sets the max level of the enchantment.@NonNull CustomEnchantment.Builderrarity(@NonNull io.papermc.paper.enchantments.EnchantmentRarity rarity)Sets the rarity of the enchantment.@NonNull CustomEnchantment.BuilderstartLevel(int startLevel)Sets the start level, or the minimum level of the enchantment.@NonNull CustomEnchantment.Buildertradeable(boolean tradeable)Sets if the enchantment is tradeable.@NonNull CustomEnchantment.BuilderSets the trade cost of the enchantment.@NonNull CustomEnchantment.Buildertreasure(boolean treasure)Sets if the enchantment is a treasure.
-
Field Details
-
name
-
namespace
-
canEnchantItem
-
enchantmentTarget
protected final org.bukkit.enchantments.EnchantmentTarget enchantmentTarget -
maxLevel
protected int maxLevel -
startLevel
protected int startLevel -
conflictList
-
treasure
protected boolean treasure -
cursed
protected boolean cursed -
tradeable
protected boolean tradeable -
discoverable
protected boolean discoverable -
rarity
protected io.papermc.paper.enchantments.EnchantmentRarity rarity -
damageIncrease
-
anvilMergeCost
-
tradeCost
-
eventListener
-
-
Constructor Details
-
Builder
public Builder(@NonNull String name, @NonNull String namespace, @NonNull Predicate<org.bukkit.inventory.ItemStack> canEnchantItem, @NonNull org.bukkit.enchantments.EnchantmentTarget enchantmentTarget)Creates a new builder for creating custom enchantments.- Parameters:
name- the name of the enchantmentnamespace- the namespace of the enchantment, a name in snake_casecanEnchantItem- the predicate to check if an item can be enchantedenchantmentTarget- the enchantment target
-
-
Method Details
-
maxLevel
Sets the max level of the enchantment.- Parameters:
maxLevel- the max level of the enchantment- Returns:
- the builder
-
startLevel
Sets the start level, or the minimum level of the enchantment.- Parameters:
startLevel- the start level of the enchantment- Returns:
- the builder
-
addConflict
public @NonNull CustomEnchantment.Builder addConflict(org.bukkit.enchantments.Enchantment... conflict)Adds a conflicting enchantment.- Parameters:
conflict- the conflicting enchantment- Returns:
- the builder
-
treasure
Sets if the enchantment is a treasure.- Parameters:
treasure- true if the enchantment is treasure, false otherwise- Returns:
- the builder
-
cursed
Sets if the enchantment is a curse.- Parameters:
cursed- true if the enchantment is a curse, false otherwise- Returns:
- the builder
-
tradeable
Sets if the enchantment is tradeable.- Parameters:
tradeable- true if the enchantment is tradeable, false otherwise- Returns:
- the builder
-
discoverable
Sets if the enchantment is discoverable.- Parameters:
discoverable- true if the enchantment is discoverable, false otherwise- Returns:
- the builder
-
rarity
public @NonNull CustomEnchantment.Builder rarity(@NonNull io.papermc.paper.enchantments.EnchantmentRarity rarity)Sets the rarity of the enchantment.- Parameters:
rarity- the rarity of the enchantment- Returns:
- the builder
-
damageIncrease
public @NonNull CustomEnchantment.Builder damageIncrease(@NonNull BiFunction<Integer,org.bukkit.entity.EntityCategory,Float> damageIncrease)Sets the damage increase of the enchantment.- Parameters:
damageIncrease- the damage increase bi-function of the enchantment- Returns:
- the builder
-
anvilMergeCost
public @NonNull CustomEnchantment.Builder anvilMergeCost(@NonNull Function<Integer,Integer> anvilMergeCost)Sets the anvil merge cost of the enchantment.- Parameters:
anvilMergeCost- the anvil merge cost function of the enchantment- Returns:
- the builder
-
tradeCost
Sets the trade cost of the enchantment.- Parameters:
tradeCost- the trade cost function of the enchantment- Returns:
- the builder
-
eventListener
public @NonNull CustomEnchantment.Builder eventListener(@Nullable @Nullable Class<? extends org.bukkit.event.Listener> eventListener)Sets the event listener of the enchantment.- Parameters:
eventListener- the event listener class of the enchantment, or null if there is no event listener- Returns:
- the builder
-
build
Builds the enchantment.- Returns:
- the enchantment
-