Class ConfigItem

java.lang.Object
de.Keyle.MyPet.api.util.ConfigItem

public class ConfigItem extends Object
A configured item — typically loaded from config (e.g., RIDE_ITEM, CONTROL_ITEM, GROW_UP_ITEM) and compared against items the player is holding.
  • Field Details

    • item

      protected ItemStack item
      The configured item this is compared against.
    • durabilityMode

      protected ConfigItem.DurabilityMode durabilityMode
      How durability is taken into account when comparing.
  • Constructor Details

    • ConfigItem

      public ConfigItem(ItemStack item, ConfigItem.DurabilityMode durabilityMode)
      Creates a config item from an existing stack.
      Parameters:
      item - the item to match
      durabilityMode - how durability should be compared
    • ConfigItem

      public ConfigItem(String data)
      Creates a config item by parsing its config form.
      Parameters:
      data - the configured item string
  • Method Details

    • createConfigItem

      public static ConfigItem createConfigItem(String data)
      Parses a configured item string.
      Parameters:
      data - the configured item string
      Returns:
      the parsed item, or null if it could not be read
    • createConfigItem

      public static ConfigItem createConfigItem(ItemStack item, ConfigItem.DurabilityMode durabilityMode)
      Wraps an existing stack as a config item.
      Parameters:
      item - the item to match
      durabilityMode - how durability should be compared
      Returns:
      the wrapped item
    • compare

      public boolean compare(ItemStack compareItem)
      Reports whether a held item matches this configured one.
      Parameters:
      compareItem - the item a player is holding
      Returns:
      true if it matches
    • load

      public void load(String data)
      Parses a modern-format item string like "minecraft:wheat[custom_name='...']" via Paper's ItemFactory.createItemStack(String).
      Parameters:
      data - the configured item string to parse
    • load

      public void load(String materialId, String data)
      Parses a legacy format where the material ID is separate from the optional NBT/components suffix. Delegates to Paper's ItemFactory.createItemStack(String) with the concatenated string, or falls back to a bare material-only ItemStack.
      Parameters:
      materialId - the material name
      data - the remaining item data to parse
    • getItem

      public ItemStack getItem()
      The configured item this is compared against.
      Returns:
      the item a held stack is matched against
    • getDurabilityMode

      public ConfigItem.DurabilityMode getDurabilityMode()
      How durability is taken into account when comparing.
      Returns:
      the durability comparison mode