Class PlaceholderProvider
java.lang.Object
ch.andre601.advancedserverlist.api.PlaceholderProvider
Abstract class used to create Placeholders in the format
${identifier values}
with identifier
being the name you provide through the Constructor.-
Constructor Summary
ConstructorDescriptionPlaceholderProvider
(String identifier) Constructor used to set the identifier for the class extending the PlaceholderProvider class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the identifier used by this instance.abstract String
parsePlaceholder
(String placeholder, GenericPlayer player, GenericServer server) This method is called by AdvancedServerList whenever a Placeholder pattern of${identifier value}
is being found.
-
Constructor Details
-
PlaceholderProvider
Constructor used to set the identifier for the class extending the PlaceholderProvider class.
Example
public class MyPlaceholders extends PlaceholderProvider { public MyPlaceholders() { super("myplaceholders"); } String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server) { if (placeholder.equals("hello") return "Hi!"; return null; } }
- Parameters:
identifier
- The identifier to use for the placeholder. Shouldn't be null, empty, nor contain spaces.
-
-
Method Details
-
parsePlaceholder
public abstract String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server) This method is called by AdvancedServerList whenever a Placeholder pattern of
${identifier value}
is being found.
Your instance of the PlaceholderProvider class is only called when the identifier matches the one you provided.null
can be returned to indicate the placeholder being invalid, having AdvancedServerList return the placeholder unchanged.- Parameters:
placeholder
- The part of the placeholder after the identifier (${<identifier> <placeholder>}
)player
- The GenericPlayer instance used.server
- The GenericServer instance used.- Returns:
- Parsed String based on the PlaceholderProvider or
null
for invalid placeholders.
-
getIdentifier
Returns the identifier used by this instance.- Returns:
- String containing the identifier used by this instance.
-