Class CustomEnchantment.Builder

java.lang.Object
com.github.imdabigboss.easydatapack.api.enchantments.CustomEnchantment.Builder
Enclosing class:
CustomEnchantment

public static class CustomEnchantment.Builder extends Object
This class represents a builder for creating custom enchantments.
  • Field Details

    • name

      protected final String name
    • namespace

      protected final String namespace
    • canEnchantItem

      protected final Predicate<org.bukkit.inventory.ItemStack> canEnchantItem
    • enchantmentTarget

      protected final org.bukkit.enchantments.EnchantmentTarget enchantmentTarget
    • maxLevel

      protected int maxLevel
    • startLevel

      protected int startLevel
    • conflictList

      protected List<org.bukkit.enchantments.Enchantment> 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

      protected BiFunction<Integer,​org.bukkit.entity.EntityCategory,​Float> damageIncrease
    • anvilMergeCost

      protected Function<Integer,​Integer> anvilMergeCost
    • tradeCost

      protected Function<Integer,​Integer> tradeCost
    • eventListener

      protected Class<? extends org.bukkit.event.Listener> 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 enchantment
      namespace - the namespace of the enchantment, a name in snake_case
      canEnchantItem - the predicate to check if an item can be enchanted
      enchantmentTarget - the enchantment target
  • Method Details

    • maxLevel

      public @NonNull CustomEnchantment.Builder maxLevel(int maxLevel)
      Sets the max level of the enchantment.
      Parameters:
      maxLevel - the max level of the enchantment
      Returns:
      the builder
    • startLevel

      public @NonNull CustomEnchantment.Builder startLevel(int 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

      public @NonNull CustomEnchantment.Builder treasure(boolean treasure)
      Sets if the enchantment is a treasure.
      Parameters:
      treasure - true if the enchantment is treasure, false otherwise
      Returns:
      the builder
    • cursed

      public @NonNull CustomEnchantment.Builder cursed(boolean cursed)
      Sets if the enchantment is a curse.
      Parameters:
      cursed - true if the enchantment is a curse, false otherwise
      Returns:
      the builder
    • tradeable

      public @NonNull CustomEnchantment.Builder tradeable(boolean tradeable)
      Sets if the enchantment is tradeable.
      Parameters:
      tradeable - true if the enchantment is tradeable, false otherwise
      Returns:
      the builder
    • discoverable

      public @NonNull CustomEnchantment.Builder discoverable(boolean 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

      public @NonNull CustomEnchantment.Builder tradeCost(@NonNull Function<Integer,​Integer> 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

      public @NonNull CustomEnchantment build()
      Builds the enchantment.
      Returns:
      the enchantment