Class ProtectionAdapter
java.lang.Object
com.winterhavenmc.library.messagebuilder.pipeline.adapters.protection.ProtectionAdapter
- All Implemented Interfaces:
Adapter
An
Adapter
implementation for adapting objects that implement the Protectable
interface.
This adapter is responsible for identifying objects that expose a protection period via
a Instant
(i.e., a protection expiration timestamp). If the provided object implements
Protectable
, it is wrapped and returned as an Optional<Protectable>
; otherwise,
an empty Optional is returned.
Once adapted, the object can be used to populate macro placeholders such as:
[OBJECT.PROTECTION.DURATION
} – a localized string showing the remaining protection time[OBJECT.PROTECTION.INSTANT
} – the formatted expiration date/time
These macros are generated using the Protectable.extractProtection(com.winterhavenmc.library.messagebuilder.keys.MacroKey, java.time.temporal.ChronoUnit, java.time.format.FormatStyle, com.winterhavenmc.library.messagebuilder.pipeline.adapters.AdapterContextContainer)
method.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.winterhavenmc.library.messagebuilder.pipeline.adapters.Adapter
Adapter.BuiltIn
-
Field Summary
Fields inherited from interface com.winterhavenmc.library.messagebuilder.pipeline.adapters.Adapter
UNKNOWN_VALUE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAttempts to adapt the given object to theProtectable
interface.
-
Constructor Details
-
ProtectionAdapter
public ProtectionAdapter()
-
-
Method Details
-
adapt
Attempts to adapt the given object to theProtectable
interface.
-