Interface DisplayNameable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
An interface representing objects that expose a display name for macro replacement.
Implementing this interface allows objects to automatically contribute to the
{OBJECT.DISPLAY_NAME}
placeholder replacement in localized message strings.
The extracted value is validated to ensure it is non-null and non-blank.
This interface is primarily used by the DisplayNameAdapter
and is supported
out of the box for Bukkit Player
, Nameable
,
and World
types.
Plugins can also implement this interface on custom types to enable automatic macro support for display names.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionA predicate used to validate that a display name is non-null and non-blank. -
Method Summary
Modifier and TypeMethodDescriptiondefault MacroStringMap
extractDisplayName
(MacroKey baseKey, AdapterContextContainer ctx) Extracts aMacroStringMap
containing the formatted display name under theDISPLAY_NAME
subkey of the given base key.formatDisplayName
(String displayName) Attempts to format and return a display name if valid.Returns the display name associated with this object.
-
Field Details
-
VALID_DISPLAY_NAME
A predicate used to validate that a display name is non-null and non-blank.
-
-
Method Details
-
getDisplayName
String getDisplayName()Returns the display name associated with this object.- Returns:
- a string representing the display name, or
null
if not available
-
extractDisplayName
Extracts aMacroStringMap
containing the formatted display name under theDISPLAY_NAME
subkey of the given base key.- Parameters:
baseKey
- the root macro key from which to derive the full macro pathctx
- the adapter context containing any contextual helpers- Returns:
- a
MacroStringMap
containing a single entry for the display name, or an empty map if the name is invalid or the key cannot be derived
-
formatDisplayName
Attempts to format and return a display name if valid.- Parameters:
displayName
- the raw display name string- Returns:
- an optional containing the display name if valid, or empty otherwise
-