Interface Expirable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Instant
.
This package defines the Expirable
interface for adapting expiration timestamps into human-readable macro values.
It enables support for both duration-based and instant-based macro replacements.
The following macro keys are supported (assuming a macro key prefix of OBJECT
):
[OBJECT.EXPIRATION.DURATION
} — A formatted duration string representing time remaining until expiration[OBJECT.EXPIRATION.INSTANT
} — A localized date/time string representing the expiration instant
The duration string is formatted using a
DurationFormatter
implementation, such as LocalizedDurationFormatter
, and the instant string is formatted using a
DateTimeFormatter
constructed with
FormatStyle
and a
LocaleProvider
.
These macros provide flexibility to server operators, allowing them to choose the display format that best suits their message context.
This adapter does not attempt to adapt Bukkit-native types. Only plugin-defined types that implement
Expirable
will be supported.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault MacroStringMap
extractExpiration
(MacroKey baseKey, ChronoUnit lowerBound, FormatStyle formatStyle, AdapterContextContainer ctx) Extracts macro key-value pairs for this object's expiration, including a formatted duration and a formatted instant string.Returns the expiration timestamp for this object.
-
Method Details
-
getExpiration
Instant getExpiration()Returns the expiration timestamp for this object.- Returns:
- an
Instant
representing when the object expires
-
extractExpiration
default MacroStringMap extractExpiration(MacroKey baseKey, ChronoUnit lowerBound, FormatStyle formatStyle, AdapterContextContainer ctx) Extracts macro key-value pairs for this object's expiration, including a formatted duration and a formatted instant string.Uses the provided macro key as a base, and appends
EXPIRATION.DURATION
andEXPIRATION.INSTANT
keys, resolving their values using the supplied formatter context.- Parameters:
baseKey
- the top-level macro key associated with this objectlowerBound
- the smallest unit of time to be displayed in the duration (e.g.,ChronoUnit.MINUTES
)formatStyle
- the formatting style for displaying the instant (e.g.,FormatStyle.MEDIUM
)ctx
- the context container with formatters and world resolvers- Returns:
- a
MacroStringMap
containing populated expiration macro keys and their string values
-