Class MessageQuery
java.lang.Object
dev.ua.theroer.magicutils.lang.MessageQuery
Fluent builder for cases that don't fit the direct
Messages.getRaw(String), Messages.get(String), or
Messages.send(Object, String) methods — primarily explicit language pinning
and manual escape-mode control.
Messages.query("plugin.welcome")
.audience(player)
.args("name", playerName)
.send();
Component c = Messages.query("plugin.error")
.language("en") // force English regardless of audience
.escaped()
.args(Map.of("error", e.getMessage()))
.component();
-
Method Summary
Modifier and TypeMethodDescriptionSets the placeholder values.Resolves the message in the recipient's preferred language.net.kyori.adventure.text.ComponentResolves to aComponent, parsing through MiniMessage.escaped()Escapes placeholder values before substitution to neutralize any MiniMessage tags they might contain.Forces resolution into the given language code, ignoring any audience preference.raw()Resolves to a plain string.voidsend()Sends the resolved component to the audience set on the builder.voidSends the resolved component to the given recipient, overriding any previously-set audience.
-
Method Details
-
audience
Resolves the message in the recipient's preferred language. Accepts any sender-like object — Audience, Player, etc.- Parameters:
recipient- Audience, platform sender, ornull- Returns:
- this builder
-
language
Forces resolution into the given language code, ignoring any audience preference.- Parameters:
languageCode- language code (e.g."en")- Returns:
- this builder
-
args
Sets the placeholder values. Accepts the same shapes asMsgFmt.apply(String, Object...): aMap, anIterable, an array, key-value pairs, or positional values.- Parameters:
args- placeholder values- Returns:
- this builder
-
escaped
Escapes placeholder values before substitution to neutralize any MiniMessage tags they might contain. Always on forcomponent()andsend(), optional forraw().- Returns:
- this builder
-
raw
-
component
public net.kyori.adventure.text.Component component()Resolves to aComponent, parsing through MiniMessage. Placeholder values are always tag-escaped.- Returns:
- adventure component
-
send
public void send()Sends the resolved component to the audience set on the builder.- Throws:
IllegalStateException- when no audience has been set
-
send
Sends the resolved component to the given recipient, overriding any previously-set audience.- Parameters:
recipient- Audience, platform sender, ornull(no-op)
-