public interface NucleusMessageTokenService
NucleusTextTemplate instances.| Modifier and Type | Interface and Description |
|---|---|
static interface |
NucleusMessageTokenService.TokenParser
A parser for tokens directed at a plugin.
|
| Modifier and Type | Method and Description |
|---|---|
default Optional<org.spongepowered.api.text.Text> |
applyPrimaryToken(String primaryToken,
org.spongepowered.api.command.CommandSource source)
Gets the result of a primary token's registered
NucleusMessageTokenService.TokenParser on a CommandSource |
default Optional<org.spongepowered.api.text.Text> |
applyPrimaryToken(String primaryToken,
org.spongepowered.api.command.CommandSource source,
Map<String,Object> variables)
Gets the result of a primary token's registered
NucleusMessageTokenService.TokenParser on a CommandSource |
default Optional<org.spongepowered.api.text.Text> |
applyToken(String plugin,
String token,
org.spongepowered.api.command.CommandSource source)
Gets the result of a token's registered
NucleusMessageTokenService.TokenParser on a CommandSource |
default Optional<org.spongepowered.api.text.Text> |
applyToken(String plugin,
String token,
org.spongepowered.api.command.CommandSource source,
Map<String,Object> variables)
Gets the result of a token's registered
NucleusMessageTokenService.TokenParser on a CommandSource |
NucleusTextTemplate |
createFromString(String string)
Creates a
NucleusTextTemplate from a string, which could be either Json or Ampersand formatted. |
Optional<org.spongepowered.api.util.Tuple<NucleusMessageTokenService.TokenParser,String>> |
getPrimaryTokenParserAndIdentifier(String primaryToken)
Gets the
NucleusMessageTokenService.TokenParser and specific token identifier for a primary token. |
List<String> |
getPrimaryTokens()
Gets the currently registered primary tokens.
|
default Optional<NucleusMessageTokenService.TokenParser> |
getTokenParser(org.spongepowered.api.plugin.PluginContainer pluginContainer)
Gets the
NucleusMessageTokenService.TokenParser for the specified PluginContainer, if it exists. |
Optional<NucleusMessageTokenService.TokenParser> |
getTokenParser(String plugin)
Gets the
NucleusMessageTokenService.TokenParser for the specified plugin id, if it exists. |
default Optional<org.spongepowered.api.text.Text> |
parseToken(String token,
org.spongepowered.api.command.CommandSource source)
Parses a token that might be either a primary token or a standard token.
|
Optional<org.spongepowered.api.text.Text> |
parseToken(String token,
org.spongepowered.api.command.CommandSource source,
Map<String,Object> variables)
Parses a token that might be either a primary token or a standard token.
|
void |
register(org.spongepowered.api.plugin.PluginContainer pluginContainer,
NucleusMessageTokenService.TokenParser parser)
Registers a
NucleusMessageTokenService.TokenParser for the specified PluginContainer. |
boolean |
registerPrimaryToken(String primaryIdentifier,
org.spongepowered.api.plugin.PluginContainer registeringPlugin,
String identiferToMapTo)
A primary token is a token that does not have a plugin identifier - such as
{{prefix}}. |
boolean |
registerTokenFormat(String tokenStart,
String tokenEnd,
String replacement)
Allows users to register additional token delimiter formats.
|
boolean |
unregister(org.spongepowered.api.plugin.PluginContainer pluginContainer)
Unregisters the
NucleusMessageTokenService.TokenParser for a plugin. |
void register(org.spongepowered.api.plugin.PluginContainer pluginContainer,
NucleusMessageTokenService.TokenParser parser)
throws PluginAlreadyRegisteredException
NucleusMessageTokenService.TokenParser for the specified PluginContainer. Plugins may only register ONE NucleusMessageTokenService.TokenParser.pluginContainer - The PluginContainer of the plugin.parser - The NucleusMessageTokenService.TokenParser that recieves the identifier from the token, along with any contextual variables and
the target MessageReceiver of the message.PluginAlreadyRegisteredException - Thrown if the token has been registered previously.boolean unregister(org.spongepowered.api.plugin.PluginContainer pluginContainer)
NucleusMessageTokenService.TokenParser for a plugin.pluginContainer - The PluginContainer of the plugin.true if successful.boolean registerPrimaryToken(String primaryIdentifier, org.spongepowered.api.plugin.PluginContainer registeringPlugin, String identiferToMapTo)
{{prefix}}. Plugins can register their
own tokens on a first come first served basis. There are some notes:
primaryIdentifier - The identifier that you wish to be able to use, without {} marks. So, if you want to register {{clan}}, the input
should be "clan".registeringPlugin - The PluginContainer of the plugin that will control this token.identiferToMapTo - The identifier that this token will map to - so if {{clan}} should map to {{pl:clans:clanname}}, this should be
clanname.true if the mapping was registered.default Optional<NucleusMessageTokenService.TokenParser> getTokenParser(org.spongepowered.api.plugin.PluginContainer pluginContainer)
NucleusMessageTokenService.TokenParser for the specified PluginContainer, if it exists.pluginContainer - The PluginContainer of the pluginContainer that registered the token.NucleusMessageTokenService.TokenParser that is run for the token, if it exists.Optional<NucleusMessageTokenService.TokenParser> getTokenParser(String plugin)
NucleusMessageTokenService.TokenParser for the specified plugin id, if it exists.plugin - The ID of the plugin that registered the token.NucleusMessageTokenService.TokenParser that is run for the token, if it exists.default Optional<org.spongepowered.api.text.Text> applyToken(String plugin, String token, org.spongepowered.api.command.CommandSource source)
NucleusMessageTokenService.TokenParser on a CommandSourceplugin - The ID of the plugin that registered the token.token - The identifier that is passed to the NucleusMessageTokenService.TokenParser.source - The CommandSource to perform the operation with.Text, if any.Optional<org.spongepowered.api.util.Tuple<NucleusMessageTokenService.TokenParser,String>> getPrimaryTokenParserAndIdentifier(String primaryToken)
NucleusMessageTokenService.TokenParser and specific token identifier for a primary token.primaryToken - The primary token, without { and } characters.Tuple with the NucleusMessageTokenService.TokenParser and specific identifier to pass to the parser.List<String> getPrimaryTokens()
default Optional<org.spongepowered.api.text.Text> applyToken(String plugin, String token, org.spongepowered.api.command.CommandSource source, Map<String,Object> variables)
NucleusMessageTokenService.TokenParser on a CommandSourceplugin - The ID of the plugin that registered the token.token - The identifier that is passed to the NucleusMessageTokenService.TokenParser.source - The CommandSource to perform the operation with.variables - The variables that could be used in the token.Text, if any.default Optional<org.spongepowered.api.text.Text> applyPrimaryToken(String primaryToken, org.spongepowered.api.command.CommandSource source)
NucleusMessageTokenService.TokenParser on a CommandSourceprimaryToken - The primary identifier that parsed.source - The CommandSource to perform the operation with.Text, if any.default Optional<org.spongepowered.api.text.Text> applyPrimaryToken(String primaryToken, org.spongepowered.api.command.CommandSource source, Map<String,Object> variables)
NucleusMessageTokenService.TokenParser on a CommandSourceprimaryToken - The primary identifier that parsed.source - The CommandSource to perform the operation with.variables - The variables that could be used in the token.Text, if any.default Optional<org.spongepowered.api.text.Text> parseToken(String token, org.spongepowered.api.command.CommandSource source)
token - The token, without the delimiters.source - The source to apply the tokens with.Optional<org.spongepowered.api.text.Text> parseToken(String token, org.spongepowered.api.command.CommandSource source, @Nullable Map<String,Object> variables)
token - The token, without the delimiters.source - The source to apply the tokens with.variables - The variables to pass to the parser.boolean registerTokenFormat(String tokenStart, String tokenEnd, String replacement) throws IllegalArgumentException
registerTokenFormat("{%", "%}", "pl:blah:$1")
Note that the third argument contains $1. This method will replace $1 with the ID.
This will only apply to Ampersand formatted strings.
tokenStart - The start delimiter of a token to register.tokenEnd - The end delimiter of a token to register.replacement - The form of the token identifier to use (without the {{,}} delimiters).true if successful.IllegalArgumentException - thrown if the delimiters are illegal.NucleusTextTemplate createFromString(String string) throws NucleusException
NucleusTextTemplate from a string, which could be either Json or Ampersand formatted.string - The string to register.NucleusTextTemplate that can be parsed.NucleusException - thrown if the string could not be parsed.