Package de.Keyle.MyPet.api.util
Class ConfigItem
java.lang.Object
de.Keyle.MyPet.api.util.ConfigItem
A configured item — typically loaded from config (e.g.,
RIDE_ITEM,
CONTROL_ITEM, GROW_UP_ITEM) and compared against items the
player is holding.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow an item's durability is taken into account when matching. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConfigItem.DurabilityModeHow durability is taken into account when comparing.protected ItemStackThe configured item this is compared against. -
Constructor Summary
ConstructorsConstructorDescriptionConfigItem(String data) Creates a config item by parsing its config form.ConfigItem(ItemStack item, ConfigItem.DurabilityMode durabilityMode) Creates a config item from an existing stack. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReports whether a held item matches this configured one.static ConfigItemcreateConfigItem(String data) Parses a configured item string.static ConfigItemcreateConfigItem(ItemStack item, ConfigItem.DurabilityMode durabilityMode) Wraps an existing stack as a config item.How durability is taken into account when comparing.getItem()The configured item this is compared against.voidParses a modern-format item string like"minecraft:wheat[custom_name='...']"via Paper'sItemFactory.createItemStack(String).voidParses a legacy format where the material ID is separate from the optional NBT/components suffix.
-
Field Details
-
item
The configured item this is compared against. -
durabilityMode
How durability is taken into account when comparing.
-
-
Constructor Details
-
ConfigItem
Creates a config item from an existing stack.- Parameters:
item- the item to matchdurabilityMode- how durability should be compared
-
ConfigItem
Creates a config item by parsing its config form.- Parameters:
data- the configured item string
-
-
Method Details
-
createConfigItem
Parses a configured item string.- Parameters:
data- the configured item string- Returns:
- the parsed item, or
nullif it could not be read
-
createConfigItem
Wraps an existing stack as a config item.- Parameters:
item- the item to matchdurabilityMode- how durability should be compared- Returns:
- the wrapped item
-
compare
Reports whether a held item matches this configured one.- Parameters:
compareItem- the item a player is holding- Returns:
trueif it matches
-
load
Parses a modern-format item string like"minecraft:wheat[custom_name='...']"via Paper'sItemFactory.createItemStack(String).- Parameters:
data- the configured item string to parse
-
load
Parses a legacy format where the material ID is separate from the optional NBT/components suffix. Delegates to Paper'sItemFactory.createItemStack(String)with the concatenated string, or falls back to a bare material-only ItemStack.- Parameters:
materialId- the material namedata- the remaining item data to parse
-
getItem
The configured item this is compared against.- Returns:
- the item a held stack is matched against
-
getDurabilityMode
How durability is taken into account when comparing.- Returns:
- the durability comparison mode
-