Interface PlaceholderContext
-
public interface PlaceholderContextContains the context that aPlaceholderParsercan use to determine what to display.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfacePlaceholderContext.BuilderA builder forPlaceholderComponentobjects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<String>argumentString()The variable string passed to this token to provide contextual information.Optional<Object>associatedObject()If provided, theObjectwhich to pull information from when building the placeholder text.static PlaceholderContext.Builderbuilder()Creates aPlaceholderContextfor aPlaceholderParserto consume.
-
-
-
Method Detail
-
builder
static PlaceholderContext.Builder builder()
Creates aPlaceholderContextfor aPlaceholderParserto consume.- Returns:
- The builder.
-
associatedObject
Optional<Object> associatedObject()
If provided, theObjectwhich 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.
PlaceholderParsers should make no assumption about the origin of the context.If an invalid
Objectis provided for the context of the placeholder, then the associatedPlaceholderParsermust return aComponent.empty().- Returns:
- The associated
Object, if any.
-
-