Soncresity Industries Wiki

Message Utilities

Allows sending and deserializing messages with the Adventure/MiniMessage API

Introduction

A fully functional Version of this class has first been introduced in Version 2.1.0

The Message Utilities class allows you to send (privately and broadcast) messages (in the chat or Action Bar) with the Adventure/MiniMessage API.

Class

File: MessageUtils.java

Package: dev.soncresityindustries.es.api.v0.util

Methods

sendClientMessage

public static void sendClientMessage(@NotNull String prefix, @NotNull ServerPlayer player, @NotNull String serializedMessage, boolean isActionBar) {}

Sends a messasge privately to the specified ServerPlayer.

Tip

If you don't want to use a prefix in the message, you can leave it empty ("").

Usage

MessageUtils.sendClientMessage(prefix, player, serializedMessage, isActionBar);

getDeserializedText (with prefix)

public static net.minecraft.network.chat.Component getDeserializedText(@NotNull String prefix, @NotNull String serializedMessage) {}

Transforms a serialized text and prefix with MiniMessage formatting into a Vanilla Chat Component while preserving its format.

Tip

If you don't want to use a prefix in the message, you can leave it empty ("") or use the getDeserializedText method.

Usage

net.minecraft.network.chat.Component component = MessageUtils.getDeserializedText(prefix, serializedMessage);

getDeserializedText

public static net.minecraft.network.chat.Component getDeserializedText(@NotNull String serializedMessage) {}

Transforms a serialized text with MiniMessage formatting into a Vanilla Chat Component while preserving its format.

Usage

net.minecraft.network.chat.Component component = MessageUtils.getDeserializedText(serializedMessage);

broadcastMessage (ServerPlayer source & with prefix)

public static void broadcastMessage(@NotNull ServerPlayer source, @NotNull String serializedMessage, boolean isActionBar) {}

Broadcasts a serialized message with a prefix to every player on the server either in the chat (isActionBar = false) or in the Action bar (isActionBar = true).

Cannot provide a `ServerPlayer` instance as the source?

Use broadcastMessage with the MinecraftServer source.

Usage

MessageUtils.broadcastMessage(source, serializedMessage, isActionBar);

broadcastMessage (ServerPlayer source`)

public static void broadcastMessage(@NotNull ServerPlayer source, @NotNull String serializedMessage, boolean isActionBar) {}

Broadcasts a serialized message to every player on the server either in the chat (isActionBar = false) or in the Action bar (isActionBar = true).

Cannot provide a `ServerPlayer` instance as the source?

Use broadcastMessage with the MinecraftServer source.

Usage

MessageUtils.broadcastMessage(source, serializedMessage, isActionBar);

broadcastMessage (MinecraftServer source & with prefix)

public static void broadcastMessage(@NotNull MinecraftServer source, @NotNull String serializedMessage, boolean actionBar) {}

Broadcasts a serialized message with a prefix to every player on the server either in the chat (isActionBar = false) or in the Action bar (isActionBar = true).

Usage

MessageUtils.broadcastMessage(source, serializedMessage, isActionBar);

broadcastMessage (MinecraftServer source)

public static void broadcastMessage(@NotNull MinecraftServer source, @NotNull String serializedMessage, boolean actionBar) {}

Broadcasts a serialized message to every player on the server either in the chat (isActionBar = false) or in the Action bar (isActionBar = true).

Usage

MessageUtils.broadcastMessage(source, serializedMessage, isActionBar);

On this page