mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-07 09:42:03 +01:00
chat stuff (#251)
This commit is contained in:
parent
62aea682c7
commit
c6cb3c0ee2
@ -22,6 +22,7 @@ import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.util.ChatUtil;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialoader.netty.ViaDecoder;
|
||||
|
||||
@ -41,7 +42,7 @@ public class ViaFabricPlusViaDecoder extends ViaDecoder {
|
||||
} catch (Throwable t) {
|
||||
ViaFabricPlus.LOGGER.error("Error occurred while decoding packet in ViaDecoder", t);
|
||||
if (mode == 1) {
|
||||
ChatUtil.sendPrefixedMessage(Formatting.RED + "An error occurred while decoding a packet! See more details in the logs!");
|
||||
ChatUtil.sendPrefixedMessage(Text.literal("An error occurred while decoding a packet! See more details in the logs!").formatted(Formatting.RED));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -23,16 +23,21 @@ import net.minecraft.util.Formatting;
|
||||
|
||||
public class ChatUtil {
|
||||
public final static String PREFIX = Formatting.WHITE + "[" + Formatting.GOLD + "ViaFabricPlus" + Formatting.WHITE + "]";
|
||||
public final static Text PREFIX_TEXT = Text.literal("[").formatted(Formatting.WHITE).append(Text.literal("ViaFabricPlus").formatted(Formatting.GOLD)).append("]");
|
||||
|
||||
public static Text prefixText(final String message) {
|
||||
return prefixText(Text.literal(message));
|
||||
}
|
||||
|
||||
public static Text prefixText(final Text message) {
|
||||
return Text.literal("").append(PREFIX).append(" " + message.getString());
|
||||
return Text.empty().append(PREFIX_TEXT).append(" ").append(message);
|
||||
}
|
||||
|
||||
public static void sendPrefixedMessage(final String message) {
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(prefixText(message));
|
||||
}
|
||||
|
||||
public static void sendPrefixedMessage(final Text message) {
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(prefixText(message));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user