Package ovh.mythmc.social.api.text.group
Class SocialParserGroup
java.lang.Object
ovh.mythmc.social.api.text.group.SocialParserGroup
- All Implemented Interfaces:
SocialContextualParser,SocialUserInputParser
Represents a group of parsers which should be processed in a single batch.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(@NotNull SocialContextualParser... parsers) Adds one or variousSocialContextualParsers to this group.get()Gets the unmodifiableListofSocialContextualParsers.<T extends SocialContextualParser>
List<T> Gets every parser matching a specific type in the group.parse(SocialParserContext context) Parses the givenSocialParserContextand returns aComponentrepresentation.voidremove(@NotNull SocialContextualParser... parsers) Removes one or variousSocialContextualParsers from this group.voidRemoves allSocialContextualParsers in this group.requestToGroup(@NotNull SocialContextualParser requester, @NotNull SocialParserContext context) Requests a specificSocialParserContextto this group and processes it.booleanChecks if this parser supports offline players.
-
Constructor Details
-
SocialParserGroup
public SocialParserGroup()
-
-
Method Details
-
get
Gets the unmodifiableListofSocialContextualParsers.- Returns:
- a
Listwith everySocialContextualParserin this group
-
add
Adds one or variousSocialContextualParsers to this group.- Parameters:
parsers- the parser or parsers to add
-
remove
Removes one or variousSocialContextualParsers from this group.- Parameters:
parsers- the parser or parsers to remove
-
removeAll
public void removeAll()Removes allSocialContextualParsers in this group. -
supportsOfflinePlayers
public boolean supportsOfflinePlayers()Description copied from interface:SocialContextualParserChecks if this parser supports offline players. The default implementation returnsfalse, but can be overridden by implementations that need to handle offline players.- Specified by:
supportsOfflinePlayersin interfaceSocialContextualParser- Returns:
trueif the parser supports offline players, otherwisefalse.
-
requestToGroup
@Experimental public Component requestToGroup(@NotNull @NotNull SocialContextualParser requester, @NotNull @NotNull SocialParserContext context) Requests a specificSocialParserContextto this group and processes it.This method is designed to be called from a
SocialContextualParserinside the group without causing any recursion issues in runtime.- Parameters:
requester- theSocialContextualParserdoing the requestcontext- theSocialParserContextto parse- Returns:
- the resulting
Componentfrom the request
-
getByType
Gets every parser matching a specific type in the group.For example,
getByType(SocialContextualPlaceholder.class)would return everySocialContextualPlaceholderin this group.- Type Parameters:
T- the type ofSocialContextualParserto get- Parameters:
type- the type ofSocialContextualParserto get- Returns:
- an unmodifiable
Listwith every parser of this type
-
parse
Description copied from interface:SocialContextualParserParses the givenSocialParserContextand returns aComponentrepresentation.- Specified by:
parsein interfaceSocialContextualParser- Parameters:
context- the context in which the message is being parsed. It contains information such as the sender, the original message, and other contextual information.- Returns:
- a
Componentrepresenting the parsed message.
-