Messages
Package: com.hypixel.hytale.server.core.Message
The Message class is the universal text type in Hytale — used for chat, commands, UI text, entity names, and notifications. It wraps the protocol-level FormattedMessage and provides a fluent builder API for styling, composition, and parameterization.
Building Messages
Section titled “Building Messages”Factory Methods
Section titled “Factory Methods”| Factory | Description |
|---|---|
Message.raw(String) | Literal text, sent as-is |
Message.translation(String) | Translation key, resolved client-side by player’s locale |
Message.empty() | Blank message — use as a container for children |
Message.join(Message...) | Concatenates multiple messages as children of an empty parent |
Message.parse(String) | Decodes a JSON-encoded message (used by /say for structured input) |
Message greeting = Message.raw("Hello!");Message translated = Message.translation("mymod.welcome");Message combined = Message.join( Message.raw("[Server] "), Message.translation("mymod.motd"));Use Message.translation() for anything player-facing. Use Message.raw() for debug output or text that shouldn’t be translated. See Translations for .lang file format, parameter syntax, and plural rules.
Formatting
Section titled “Formatting”All style methods modify the message in-place and return this for chaining.
Text Styles
Section titled “Text Styles”Message.raw("Important").bold(true);Message.raw("Emphasis").italic(true);Message.raw("Code output").monospace(true);| Method | Effect |
|---|---|
.bold(true) | Bold text |
.italic(true) | Italic text |
.monospace(true) | Monospace font |
Underline exists at the protocol level (FormattedMessage.underlined) but has no convenience method on Message. To set it, access the underlying object:
message.getFormattedMessage().underlined = MaybeBool.True;Colors
Section titled “Colors”Colors are hex strings — no named color enum.
// hex stringMessage.raw("Warning!").color("#F2D729");Message.raw("Error").color("#ff5555");
// java.awt.Color constantMessage.raw("Enabled").color(Color.GREEN);Message.raw("Disabled").color(Color.RED);The hex string accepts #RGB, #RRGGBB, and #RRGGBBAA formats. The .color(Color) overload converts via ColorParseUtil.colorToHex().
Message.raw("Click here").link("https://example.com");The link field stores a URL string on the protocol message. The client renders it as a clickable link.
Style Inheritance
Section titled “Style Inheritance”Styles use a tri-state system (MaybeBool): Null (inherit from parent), True, or False. When you build a message tree with children, unstyled children inherit their parent’s formatting. Passing false explicitly resets an inherited style:
Message parent = Message.empty().bold(true);parent.insert(Message.raw("This is bold ")); // inherits boldparent.insert(Message.raw("this is not").bold(false)); // explicitly resetsComposing Messages
Section titled “Composing Messages”Messages form a tree — each message can have children that render in sequence after the parent’s own text.
insert and insertAll
Section titled “insert and insertAll”// append a child messageMessage msg = Message.empty();msg.insert(Message.raw("Line 1\n"));msg.insert(Message.raw("Line 2\n"));
// append multiple childrenmsg.insertAll(Message.raw("A"), Message.raw("B"), Message.raw("C"));.insert() also accepts a plain String (wraps it in Message.raw() internally).
Message.join() creates an empty parent and adds all arguments as children:
Message dialog = Message.join( Message.translation("mymod.npc.name"), Message.raw(": "), Message.translation("mymod.npc.dialog"));Building Lists
Section titled “Building Lists”// build a list incrementallyMessage list = Message.empty();for (String item : items) { list.insert(Message.raw("- " + item + "\n"));}Parameters
Section titled “Parameters”Parameters use {key} placeholders in translation strings. The .param() method accepts several value types directly:
| Value Type | Example |
|---|---|
String | .param("name", playerName) |
int | .param("count", 5) |
long | .param("id", entityId) |
float | .param("speed", 1.5f) |
double | .param("x", position.getX()) |
boolean | .param("enabled", true) |
Message | .param("target", Message.translation("...")) |
playerRef.sendMessage(Message.translation("mymod.healed") .param("name", targetName) .param("amount", healAmount));Nested Message Parameters
Section titled “Nested Message Parameters”Pass a Message as a parameter to embed styled or translated fragments inside a translation:
// styled name inside a translated stringMessage msg = Message.translation("mymod.banned") .param("player", Message.raw(username).bold(true).color(Color.RED));
// nested translationMessage msg = Message.translation("mymod.objective.completed") .param("title", Message.translation(objective.getTitleKey()));The .lang file uses {paramName} regardless of whether the value is a scalar or nested Message:
mymod.banned = {player} has been bannedmymod.objective.completed = Completed: {title}Primitive params and message params are stored in separate maps internally (params for scalars, messageParams for nested messages).
For format specifiers ({key, upper}, {key, number}, {key, plural, ...}), see Translations.
Mutability
Section titled “Mutability”Messages are mutable — .bold(), .color(), .insert() and other methods modify the message in-place and return this. Don’t reuse a message object after styling:
// the bold leaks to the console send tooMessage name = Message.raw(username);sendToPlayer(name.bold(true));sendToConsole(name); // also boldBuild each message separately:
sendToPlayer(Message.raw(username).bold(true));sendToConsole(Message.raw(username));Sending Messages
Section titled “Sending Messages”Any class implementing IMessageReceiver can receive messages — this includes Player, PlayerRef, and ConsoleSender.
To One Player
Section titled “To One Player”playerRef.sendMessage(Message.translation("mymod.welcome"));To a World
Section titled “To a World”world.sendMessage(Message.translation("world.event.started"));To All Players
Section titled “To All Players”Universe universe = Universe.get();universe.sendMessage(Message.raw("Server restart in 5 minutes"));With Visibility Filtering
Section titled “With Visibility Filtering”Package: com.hypixel.hytale.server.core.universe.world.PlayerUtil
// broadcast message — players who have the sender hidden won't receive itPlayerUtil.broadcastMessageToPlayers(senderUuid, message, store);See Visibility for the hidden players system.
Raw Packet Broadcasting
Section titled “Raw Packet Broadcasting”For sending arbitrary packets (not just messages):
// to all players in a worldPlayerUtil.broadcastPacketToPlayers(componentAccessor, packet);
// to all players server-wideUniverse.get().broadcastPacket(packet);Utility Classes
Section titled “Utility Classes”MessageFormat
Section titled “MessageFormat”Package: com.hypixel.hytale.server.core.util.message.MessageFormat
Pre-built message patterns used across commands:
// returns green "enabled" or red "disabled" messageMessage status = MessageFormat.enabled(isEnabled);
// formats a list: inline with commas (4 or fewer) or newline-delimited (5+)Message list = MessageFormat.list(headerMessage, valueMessages);Console Output
Section titled “Console Output”Message.getAnsiMessage() resolves the message to plain text for console/logging. For translations, it looks up the en-US locale server-side and substitutes parameters:
String consoleText = message.getAnsiMessage();Packets
Section titled “Packets”Message delivery is packet-based. See Interface Packets for field details: ServerMessage, ChatMessage, KillFeedMessage.
PlayerRef.sendMessage() writes a ServerMessage packet with ChatType.Chat.