Package valorless.rarespawns.utils
Class EnchantmentParser
java.lang.Object
valorless.rarespawns.utils.EnchantmentParser
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 Summary
Constructors -
Method Summary
-
Constructor Details
-
EnchantmentParser
public EnchantmentParser()
-
-
Method Details
-
Parse
Parses an enchantment by its configured name.Delegates to
Enchantment.getByName(String)and wraps invalid input by throwingInvalidEnchantmentwith 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
-