Interface MessageContext
- All Known Subinterfaces:
AFKMessageContext, BallMessageContext, ChatMessageContext, ClearMessageContext, CoinMessageContext, ComponentMessageContext, DeletemessageMessageContext, DiceMessageContext, DiscordMessageContext, ExternalModerationMessageContext, GeolocateMessageContext, IgnoreMessageContext, JoinMessageContext, MailMessageContext, MaintenanceMessageContext, MinesweeperMessageContext, ModerationMessageContext, NicknameMessageContext, OnlineMessageContext, PollMessageContext, QuestionAnswerMessageContext, RightClickMessageContext, RockPaperScissorsMessageContext, SpyMessageContext, StreamMessageContext, StringMessageContext, TelegramMessageContext, TellMessageContext, TicTacToeMessageContext, TranslatetoMessageContext, TryMessageContext, TwitchMessageContext, UpdateMessageContext, VanillaMessageContext, VanishMessageContext, WhitelistMessageContext
public interface MessageContext
One message on its way to one receiver, carrying the raw text, who sent it, who reads it,
the MiniMessage tags resolved so far and the flags that switch formatting steps on or off.
Contexts are immutable. The with* and add* methods return a modified copy,
and richer variants such as StringMessageContext wrap a base context to carry extra data.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceIdentifies a rendered message so an identical one can be served from cache instead of being formatted again. -
Method Summary
Modifier and TypeMethodDescriptiondefault MessageContextaddFlag(@NonNull MessageFlag flag, boolean value) Returns a copy with one flag set, keeping the rest.default MessageContextaddFlags(MessageFlag @NonNull [] flags, boolean @NonNull [] values) Returns a copy with several flags set, keeping the rest.default MessageContextaddTagResolver(@Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver) Returns a copy with one more tag resolver layered on top of the current ones.default MessageContextaddTagResolvers(@NonNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... resolvers) Returns a copy with several tag resolvers layered on top of the current ones.base()The plain context underneath this one.static net.flectone.pulse.model.event.message.context.MessageContextImpl.MessageContextImplBuilderbuilder()Starts building a message context.default MessageContext.CacheKeyBuilds the cache key for this context.default @NonNull Map<MessageFlag, Boolean> flags()The formatting switches applied to this message.default booleanisFlag(MessageFlag flag) Whether a flag is on, falling back to the flag's own default when it was never set.default @NonNull Stringmessage()The raw, unrendered text.default @NonNull FPlayerreceiver()Who this copy of the message is for.default @NonNull FEntitysender()Who sent the message.default @NonNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolverThe MiniMessage tags available while rendering this message.default net.flectone.pulse.model.event.message.context.MessageContextImpl.MessageContextImplBuilderStarts a builder pre-filled with this context's values.default @NonNull UUIDuuid()The id shared by every per-receiver copy of the same message.default MessageContextwithBase(@NonNull MessageContext base) Returns a copy with a different base context.default MessageContextwithFlags(@NonNull Map<MessageFlag, Boolean> flags) Returns a copy with the flags replaced.default MessageContextwithMessage(@NonNull String message) Returns a copy with different text.default MessageContextwithReceiver(@NonNull FPlayer receiver) Returns a copy aimed at a different receiver.default MessageContextwithSender(@NonNull FEntity sender) Returns a copy with a different sender.default MessageContextwithTagResolver(@NonNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver) Returns a copy with the tag resolver replaced.default MessageContextReturns a copy with a different message id.
-
Method Details
-
builder
static net.flectone.pulse.model.event.message.context.MessageContextImpl.MessageContextImplBuilder builder()Starts building a message context.- Returns:
- a new builder
-
base
MessageContext base()The plain context underneath this one. Wrapping contexts delegate their shared fields to it.- Returns:
- the base context
-
toBuilder
default net.flectone.pulse.model.event.message.context.MessageContextImpl.MessageContextImplBuilder toBuilder()Starts a builder pre-filled with this context's values.- Returns:
- the pre-filled builder
-
flags
The formatting switches applied to this message.- Returns:
- the flags, keyed by name
-
tagResolver
default @NonNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver()The MiniMessage tags available while rendering this message.- Returns:
- the resolver
-
sender
-
receiver
-
uuid
The id shared by every per-receiver copy of the same message.- Returns:
- the message id
-
message
-
withBase
Returns a copy with a different base context.- Parameters:
base- the new base- Returns:
- the copy
-
withFlags
Returns a copy with the flags replaced.- Parameters:
flags- the new flags- Returns:
- the copy
-
withTagResolver
default MessageContext withTagResolver(@NonNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver) Returns a copy with the tag resolver replaced.- Parameters:
tagResolver- the new resolver- Returns:
- the copy
-
withSender
Returns a copy with a different sender.- Parameters:
sender- the new sender- Returns:
- the copy
-
withReceiver
Returns a copy aimed at a different receiver.- Parameters:
receiver- the new receiver- Returns:
- the copy
-
withUuid
Returns a copy with a different message id.- Parameters:
uuid- the new id- Returns:
- the copy
-
withMessage
Returns a copy with different text.- Parameters:
message- the new text- Returns:
- the copy
-
isFlag
Whether a flag is on, falling back to the flag's own default when it was never set.- Parameters:
flag- the flag to read- Returns:
- the flag state
-
addFlag
Returns a copy with one flag set, keeping the rest.- Parameters:
flag- the flag to setvalue- the new state- Returns:
- the copy
-
addFlags
Returns a copy with several flags set, keeping the rest.- Parameters:
flags- the flags to setvalues- the matching states- Returns:
- the copy, or this instance if either array is empty
- Throws:
IllegalArgumentException- if the two arrays differ in length
-
addTagResolver
default MessageContext addTagResolver(@Nullable net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver) Returns a copy with one more tag resolver layered on top of the current ones.- Parameters:
tagResolver- the resolver to add, may be null- Returns:
- the copy, or this instance if the resolver was null
-
addTagResolvers
default MessageContext addTagResolvers(@NonNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... resolvers) Returns a copy with several tag resolvers layered on top of the current ones.- Parameters:
resolvers- the resolvers to add- Returns:
- the copy, or this instance if nothing was passed
-
createCacheKey
Builds the cache key for this context.- Returns:
- the key
-