Interface Adapter
- All Known Implementing Classes:
DisplayNameAdapter
,DurationAdapter
,ExpirationAdapter
,InstantAdapter
,KillerAdapter
,LocationAdapter
,LooterAdapter
,NameAdapter
,OwnerAdapter
,ProtectionAdapter
,QuantityAdapter
,UniqueIdAdapter
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
- exposesgetName()
fieldLocatable
- exposes aLocation
, mapped to multiple subfieldsExpirable
- exposes aDuration
andInstant
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 ClassesModifier and TypeInterfaceDescriptionstatic enum
Enumeration of all built-in adapter types supported by the message builder pipeline. -
Field Summary
Fields -
Method Summary
-
Field Details
-
UNKNOWN_VALUE
- See Also:
-
-
Method Details
-
adapt
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 emptyOptional
is returned.- Parameters:
object
- the object to evaluate and adapt- Returns:
- an optional adapted representation, or empty if not supported
-
supports
Returnstrue
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
-