Class EnchantmentParser

java.lang.Object
com.ultikits.ultitools.abstracts.command.parser.EnchantmentParser
All Implemented Interfaces:
TypeParser<org.bukkit.enchantments.Enchantment>

public class EnchantmentParser extends Object implements TypeParser<org.bukkit.enchantments.Enchantment>
Type parser for Bukkit Enchantment. Supports parsing by name (e.g., "SHARPNESS", "PROTECTION").

Bukkit Enchantment 类型解析器。 支持通过名称解析(例如 "SHARPNESS"、"PROTECTION")。

Since:
6.2.0
  • Constructor Details

    • EnchantmentParser

      public EnchantmentParser()
  • Method Details

    • getPrimaryType

      public Class<org.bukkit.enchantments.Enchantment> getPrimaryType()
      Description copied from interface: TypeParser
      Gets the primary type this parser handles. 获取此解析器处理的主要类型。
      Specified by:
      getPrimaryType in interface TypeParser<org.bukkit.enchantments.Enchantment>
      Returns:
      the primary type class
    • getSupportedTypes

      public List<Class<?>> getSupportedTypes()
      Description copied from interface: TypeParser
      Gets all types this parser can handle, including array types. 获取此解析器可以处理的所有类型,包括数组类型。
      Specified by:
      getSupportedTypes in interface TypeParser<org.bukkit.enchantments.Enchantment>
      Returns:
      list of supported types
    • parse

      public org.bukkit.enchantments.Enchantment parse(String value) throws TypeParseException
      Description copied from interface: TypeParser
      Parses a string value into the target type. 将字符串值解析为目标类型。
      Specified by:
      parse in interface TypeParser<org.bukkit.enchantments.Enchantment>
      Parameters:
      value - the string value to parse
      Returns:
      the parsed value, or null if parsing fails
      Throws:
      TypeParseException - if parsing fails with an error
    • parseArray

      public org.bukkit.enchantments.Enchantment[] parseArray(String[] values) throws TypeParseException
      Description copied from interface: TypeParser
      Parses multiple string values into an array of the target type. Default implementation calls parse() for each value. 将多个字符串值解析为目标类型的数组。 默认实现为每个值调用 parse()。
      Specified by:
      parseArray in interface TypeParser<org.bukkit.enchantments.Enchantment>
      Parameters:
      values - the string values to parse
      Returns:
      the parsed array
      Throws:
      TypeParseException - if parsing fails with an error