Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface DisplayNameable
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 Details

    • VALID_DISPLAY_NAME

      static final Predicate<String> 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

      default MacroStringMap extractDisplayName(MacroKey baseKey, AdapterContextContainer ctx)
      Extracts a MacroStringMap containing the formatted display name under the DISPLAY_NAME subkey of the given base key.
      Parameters:
      baseKey - the root macro key from which to derive the full macro path
      ctx - 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

      static Optional<String> formatDisplayName(String displayName)
      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