Package ovh.mythmc.social.api.context
Class SocialParserContext
java.lang.Object
ovh.mythmc.social.api.context.SocialParserContext
- All Implemented Interfaces:
SocialContext
- Direct Known Subclasses:
SocialProcessorContext
Represents the parsing context of a message before it is formatted
or dispatched.
A SocialParserContext provides all necessary information required
during the parsing phase of a message, including:
- The
SocialUserwho sent the message - The
ChatChannelthe message is associated with - The raw
Componentmessage content - The
ChatChannel.ChannelTypeof the message - An optional
SocialParserGroupdefining parser behavior - A collection of
injected values
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSocialParserContext.Builder<T extends SocialParserContext.Builder<?,?>, R> Base builder implementation forSocialParserContext.static classDefault builder implementation forSocialParserContext. -
Method Summary
Modifier and TypeMethodDescriptionbuilder(@NotNull SocialUser user, @NotNull Component message) Creates a newSocialParserContext.SocialParserContextBuilderfor the given user and message.<V> VgetInjectedValue(@NotNull String identifier) Retrieves an injected value by its identifier.<V> VgetInjectedValue(@NotNull String identifier, V defaultValue) Retrieves an injected value by its identifier, returning a default value if none is found.group()Returns the parser group if present.List<SocialInjectedValue<?, ?>> Returns an immutable copy of the injected values.<T extends SocialInjectedValue<?,?>>
List<T> injectedValues(@NotNull Class<T> type) Returns all injected values of the specified type.voidinjectValue(@NotNull SocialInjectedValue<?, ?> injectedValue) Injects a single value into this context.voidinjectValues(@NotNull Iterable<? extends SocialInjectedValue<?, ?>> injectedValues) Injects multiple values into this context.
-
Method Details
-
builder
public static SocialParserContext.SocialParserContextBuilder builder(@NotNull @NotNull SocialUser user, @NotNull @NotNull Component message) Creates a newSocialParserContext.SocialParserContextBuilderfor the given user and message.- Parameters:
user- the user sending the messagemessage- the raw message component- Returns:
- a new builder instance
-
group
Returns the parser group if present.- Returns:
- an
Optionalcontaining theSocialParserGroup, or empty if none is set
-
injectedValues
Returns an immutable copy of the injected values.- Returns:
- an unmodifiable list of injected values
-
injectedValues
public <T extends SocialInjectedValue<?,?>> List<T> injectedValues(@NotNull @NotNull Class<T> type) Returns all injected values of the specified type.- Type Parameters:
T- the injected value subtype- Parameters:
type- the injected value type- Returns:
- a list of injected values matching the given type
-
injectValue
Injects a single value into this context.- Parameters:
injectedValue- the value to inject
-
injectValues
public void injectValues(@NotNull @NotNull Iterable<? extends SocialInjectedValue<?, ?>> injectedValues) Injects multiple values into this context.- Parameters:
injectedValues- the values to inject
-
getInjectedValue
Retrieves an injected value by its identifier.- Type Parameters:
V- the value type- Parameters:
identifier- the unique identifier- Returns:
- the injected value, or
nullif not present
-
getInjectedValue
Retrieves an injected value by its identifier, returning a default value if none is found.- Type Parameters:
V- the value type- Parameters:
identifier- the unique identifierdefaultValue- the value to return if no match is found- Returns:
- the injected value or
defaultValueif not present
-