Class SocialContextualPlaceholder
java.lang.Object
ovh.mythmc.social.api.text.parser.SocialContextualPlaceholder
- All Implemented Interfaces:
SocialContextualParser,SocialIdentifiedParser
The
SocialContextualPlaceholder class provides a base for parsing and replacing placeholders
in messages based on a specific context. This class is an abstract implementation of the
SocialIdentifiedParser interface, allowing subclasses to define custom placeholder replacements
that are context-sensitive.
This class is primarily used to replace placeholders in a message with dynamically generated
content based on the social context. The placeholder format is expected to be of the form
$(identifier) where the identifier is a unique string identifying the placeholder.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Componentget(SocialParserContext context) Retrieves the replacement component for the placeholder based on the given context.booleanDeprecated.since version 0.4.parse(SocialParserContext context) Parses the context and replaces the placeholder with the appropriate content.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ovh.mythmc.social.api.text.parser.SocialContextualParser
supportsOfflinePlayersMethods inherited from interface ovh.mythmc.social.api.text.parser.SocialIdentifiedParser
identifier
-
Constructor Details
-
SocialContextualPlaceholder
public SocialContextualPlaceholder()
-
-
Method Details
-
get
Retrieves the replacement component for the placeholder based on the given context.- Parameters:
context- the social context in which the placeholder is being parsed.- Returns:
- a
Componentrepresenting the replacement content for the placeholder.
-
legacySupport
Deprecated.since version 0.4. This method is no longer necessary and will be removed in future versions.Checks if the placeholder supports the legacy format. The default implementation returnsfalse. This method is deprecated and should not be used in future versions.- Returns:
trueif legacy support is enabled, otherwisefalse.
-
parse
Parses the context and replaces the placeholder with the appropriate content. This method uses regular expressions to match placeholders in the format$(identifier)or the legacy format$identifier. If the legacy format is supported, both formats will be matched.It utilizes the context’s message to replace the placeholder, returning a new message with the placeholder replaced by the component generated from the
get(SocialParserContext)method.- Specified by:
parsein interfaceSocialContextualParser- Parameters:
context- the social context in which the placeholder is being parsed.- Returns:
- a
Componentrepresenting the modified message with the placeholder replaced.
-