Interface Quantifiable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents objects that expose a numerical quantity for macro replacement.
This interface allows objects to contribute to the {OBJECT.QUANTITY}
placeholder
using an integer-based getQuantity()
accessor. Implementing this interface enables
plugins to automatically extract and localize quantity values from plugin-defined or
Bukkit-provided objects.
Common examples of quantities include item stack sizes, inventory capacities, or collection sizes.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault MacroStringMap
extractQuantity
(MacroKey baseKey, AdapterContextContainer ctx) Extracts aMacroStringMap
containing the formatted quantity string.formatQuantity
(int quantity, NumberFormatter numberFormatter) Converts a raw integer quantity into a localized string using the provided number formatter.int
Returns the numeric quantity associated with this object.
-
Method Details
-
getQuantity
int getQuantity()Returns the numeric quantity associated with this object.- Returns:
- the quantity as an integer
-
extractQuantity
Extracts aMacroStringMap
containing the formatted quantity string. This value will be added using the subkeyQUANTITY
of the provided macro key.- Parameters:
baseKey
- the macro key under which to store the formatted quantityctx
- the adapter context providing the number formatter- Returns:
- a
MacroStringMap
with a formatted quantity string, or an empty map if the key cannot be derived
-
formatQuantity
Converts a raw integer quantity into a localized string using the provided number formatter.- Parameters:
quantity
- the raw integer quantitynumberFormatter
- the number formatter used for localization- Returns:
- an optional containing the formatted string
-