Class EnchantmentParser

java.lang.Object
valorless.rarespawns.utils.EnchantmentParser

public class EnchantmentParser extends Object
Utility for parsing Bukkit Enchantment instances from string identifiers.

Uses Enchantment.getByName(String) for broad version compatibility. Note: getByName is deprecated in modern Bukkit versions; prefer NamespacedKey-based lookups when available. This helper preserves legacy behavior used by configs.

  • Constructor Details

    • EnchantmentParser

      public EnchantmentParser()
  • Method Details

    • Parse

      public static org.bukkit.enchantments.Enchantment Parse(String enchant)
      Parses an enchantment by its configured name.

      Delegates to Enchantment.getByName(String) and wraps invalid input by throwing InvalidEnchantment with a descriptive message.

      Parameters:
      enchant - the enchantment name as used in configuration (e.g., "SHARPNESS")
      Returns:
      the resolved Enchantment
      Throws:
      InvalidEnchantment - if the provided name does not map to a known enchantment