All Known Implementing Classes:
DisplayNameAdapter, DurationAdapter, ExpirationAdapter, InstantAdapter, KillerAdapter, LocationAdapter, LooterAdapter, NameAdapter, OwnerAdapter, ProtectionAdapter, QuantityAdapter, UniqueIdAdapter

public interface Adapter
A functional interface representing an adapter capable of extracting macro-relevant data from an object.

Adapters are responsible for converting arbitrary plugin or Bukkit types into structured representations that expose specific fields used in macro substitution. This enables dynamic replacement of placeholders in message templates with values derived from complex or nested objects.

Each Adapter implementation defines logic for a particular type or interface contract, such as:

  • Nameable - exposes getName() field
  • Locatable - exposes a Location, mapped to multiple subfields
  • Expirable - exposes a Duration and Instant

Adapters return values wrapped in Optional, allowing the pipeline to gracefully skip unsupported types. Compound adapters may populate multiple subfields (e.g., LOCATION.WORLD, EXPIRATION.DURATION, etc.).

Plugin developers can participate in macro resolution by implementing supported interfaces like Nameable, Locatable, Expirable, and others in their own types.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Enumeration of all built-in adapter types supported by the message builder pipeline.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    adapt(Object object)
    Attempts to adapt the given object to a type-specific representation for macro extraction.
    default boolean
    supports(Object object)
    Returns true if this adapter can successfully adapt the given object.
  • Field Details

  • Method Details

    • adapt

      Optional<?> adapt(Object object)
      Attempts to adapt the given object to a type-specific representation for macro extraction.

      This method may return a known interface (e.g., Nameable) or a domain object suitable for field extraction by a resolver. If the object is not compatible, an empty Optional is returned.

      Parameters:
      object - the object to evaluate and adapt
      Returns:
      an optional adapted representation, or empty if not supported
    • supports

      default boolean supports(Object object)
      Returns true if this adapter can successfully adapt the given object.

      This is equivalent to checking adapt(object).isPresent() and is typically used to filter compatible types before performing macro resolution.

      Parameters:
      object - the object to check
      Returns:
      true if the object is supported by this adapter