Class TeamEnchantment

java.lang.Object
de.marcely.bedwars.api.game.upgrade.TeamEnchantment

public class TeamEnchantment extends Object
Represents an enchantment that is being applied to all items of a specific type for all team members
  • Constructor Details

    • TeamEnchantment

      public TeamEnchantment(TeamEnchantment.Target target, Enchantment ench, int lvl)
      Parameters:
      target - The item type it should target
      ench - The enchantment
      lvl - The level of the enchantment
    • TeamEnchantment

      public TeamEnchantment(Predicate<ItemStack> targetPredicate, String targetId, Enchantment ench, int lvl)

      You generally should use TeamEnchantment(Target, Enchantment, int) instead. This constructor, however, allows you to be more precise with the items that should be enchanted.

      The targetPredicate should always return the same result for the same material. If it does not, then unexpected behavior might occur.

      Parameters:
      targetPredicate - The predicate that determines if an item should be enchanted
      targetId - The id of the target. Multiple enchantments with the same targetId will be combined into one
      ench - The enchantment
      lvl - The level of the enchantment
  • Method Details

    • getTarget

      public TeamEnchantment.Target getTarget()
      Get the broad item target this enchantment should target.
      Returns:
      The items for which the enchantment gets applied on
    • isApplicable

      public boolean isApplicable(ItemStack is)
      Get whether this enchantment is applicable to the given material.

      E.g. if the target is TeamEnchantment.Target.PICKAXE and the material is Material.DIAMOND_PICKAXE, this method would return true. If the material would however be Material.DIRT, this method would return false.

      Parameters:
      is - The item to test
      Returns:
      true if the enchantment is applicable, false otherwise
    • getTargetId

      public String getTargetId()
      Get the id of the target.

      If a player buys an enchantment with the same targetId multiple times, then the older one with the equal targetId will be replaced by the newer one.

      Built-in targets (those that are not TeamEnchantment.Target.CUSTOM) will return Enum.name().

      Returns:
      The id of the target
    • getEnchantment

      public Enchantment getEnchantment()
      Get the enchantment that shall be applied on the items.
      Returns:
      The enchantment that gets applied
    • getLevel

      public int getLevel()
      Get the level of the enchantment that gets applied
      Returns:
      The level of the enchantment that gets applied