summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2024-01-20 02:22:09 +0800
committerKeuin <[email protected]>2024-01-20 02:38:32 +0800
commit5f59fa90caae0e65b19282beae6d1432255e1c18 (patch)
tree6c9e7eff6ed810813adc48f2075bb0ce2eb0de37 /src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java
parent381843f39f6e896e153cff75b6d16f4481ed2495 (diff)
mc 1.16.4
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java b/src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java
index 34b548a..25334bc 100644
--- a/src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java
+++ b/src/main/java/com/keuin/kbackupfabric/util/PrintUtil.java
@@ -1,6 +1,7 @@
package com.keuin.kbackupfabric.util;
import com.mojang.brigadier.context.CommandContext;
+import net.minecraft.network.MessageType;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
@@ -12,6 +13,7 @@ import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import java.util.Optional;
+import java.util.UUID;
public final class PrintUtil {
@@ -19,11 +21,11 @@ public final class PrintUtil {
private static final Object syncMessage = new Object();
private static final Object syncBroadcast = new Object();
- private static final Style broadcastStyle = new Style().setColor(Formatting.AQUA);
- private static final Style infoStyle = new Style().setColor(Formatting.WHITE);
- private static final Style stressStyle = new Style().setColor(Formatting.AQUA);
- private static final Style warnStyle = new Style().setColor(Formatting.YELLOW);
- private static final Style errorStyle = new Style().setColor(Formatting.DARK_RED);
+ private static final Style broadcastStyle = Style.EMPTY.withColor(Formatting.AQUA);
+ private static final Style infoStyle = Style.EMPTY.withColor(Formatting.WHITE);
+ private static final Style stressStyle = Style.EMPTY.withColor(Formatting.AQUA);
+ private static final Style warnStyle = Style.EMPTY.withColor(Formatting.YELLOW);
+ private static final Style errorStyle = Style.EMPTY.withColor(Formatting.DARK_RED);
private static final Logger LOGGER = LogManager.getLogger();
private static PlayerManager playerManager = null;
@@ -41,7 +43,8 @@ public final class PrintUtil {
synchronized (syncBroadcast) {
Optional.ofNullable(playerManager)
.ifPresent(pm ->
- pm.sendToAll(new LiteralText(message).setStyle(style)));
+ pm.broadcastChatMessage(new LiteralText(message).setStyle(style),
+ MessageType.CHAT, UUID.randomUUID()));
}
}
@@ -80,8 +83,7 @@ public final class PrintUtil {
private static CommandContext<ServerCommandSource> message(@Nullable CommandContext<ServerCommandSource> context, String messageText, boolean broadcastToOps, Style style) {
if (context != null) {
synchronized (syncMessage) {
- Text text = new LiteralText(messageText);
- text.setStyle(style);
+ Text text = new LiteralText(messageText).setStyle(style);
context.getSource().sendFeedback(text, broadcastToOps);
}
return context;