From c25d93968ba190021bf02b4018c94595c88e446b Mon Sep 17 00:00:00 2001 From: Chipmunk <65827213+ChipmunkMC@users.noreply.github.com> Date: Sat, 29 Apr 2023 23:20:10 -0400 Subject: [PATCH] tellraw fallbacks (more coming soon:tm:) --- .../java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java index d740047..a3e438d 100644 --- a/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java +++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java @@ -5,6 +5,7 @@ import land.chipmunk.chipmunkbot.data.chat.PlayerMessage; import land.chipmunk.chipmunkbot.data.chat.SystemChatParser; import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry; import land.chipmunk.chipmunkbot.util.UUIDUtilities; +import land.chipmunk.chipmunkbot.util.ComponentUtilities; // sus import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket; @@ -106,7 +107,10 @@ public class ChatPlugin extends SessionAdapter { // ? Should this be here? public void tellraw (Component message, String targets) { - client.core.run("minecraft:tellraw " + targets + " " + GsonComponentSerializer.gson().serialize(message)); + final int maxLength = client.core().maxCommandLength(); + String command = "minecraft:tellraw " + targets + " " + GsonComponentSerializer.gson().serialize(message); + if (command.length() > maxLength) command = "w " + targets + " " + ComponentUtilities.stringify(message); + client.core().run(command); } public void tellraw (Component message) { tellraw(message, "@a"); } public void tellraw (Component message, UUID uuid) { tellraw(message, UUIDUtilities.selector(uuid)); }