Interface PlaceholderContext
-
public interface PlaceholderContext
Contains the context that aPlaceholderParser
can use to determine what to display.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
PlaceholderContext.Builder
A builder forPlaceholderComponent
objects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Optional<java.lang.String>
argumentString()
The variable string passed to this token to provide contextual information.java.util.Optional<java.lang.Object>
associatedObject()
If provided, theObject
which to pull information from when building the placeholder text.static PlaceholderContext.Builder
builder()
Creates aPlaceholderContext
for aPlaceholderParser
to consume.
-
-
-
Method Detail
-
builder
static PlaceholderContext.Builder builder()
Creates aPlaceholderContext
for aPlaceholderParser
to consume.- Returns:
- The builder.
-
associatedObject
java.util.Optional<java.lang.Object> associatedObject()
If provided, theObject
which to pull information from when building the placeholder text.Examples of how this might affect a placeholder are:
- For a "name" placeholder that prints out the source's name, the name would be selected from this source.
- For a "current world" placeholder that returns a player's current world, this would pull the name of that current world from the player.
It is important to note that the associated context does not necessarily have to be the sender/invoker of a message, nor does it have to be the recipient. The source is selected by the context of builder. It is up to plugins that use such placeholders to be aware of the context of which the placeholder is used.
PlaceholderParser
s should make no assumption about the origin of the context.If an invalid
Object
is provided for the context of the placeholder, then the associatedPlaceholderParser
must return aComponent.empty()
.- Returns:
- The associated
Object
, if any.
-
argumentString
java.util.Optional<java.lang.String> argumentString()
The variable string passed to this token to provide contextual information.- Returns:
- The argument, if any
-
-