tellraw fallbacks (more coming soon™️)

This commit is contained in:
Chipmunk 2023-04-29 23:20:10 -04:00
parent 00e5acfde3
commit c25d93968b

View file

@ -5,6 +5,7 @@ import land.chipmunk.chipmunkbot.data.chat.PlayerMessage;
import land.chipmunk.chipmunkbot.data.chat.SystemChatParser; import land.chipmunk.chipmunkbot.data.chat.SystemChatParser;
import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry; import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry;
import land.chipmunk.chipmunkbot.util.UUIDUtilities; 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.ClientboundSystemChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket;
@ -106,7 +107,10 @@ public class ChatPlugin extends SessionAdapter {
// ? Should this be here? // ? Should this be here?
public void tellraw (Component message, String targets) { 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) { tellraw(message, "@a"); }
public void tellraw (Component message, UUID uuid) { tellraw(message, UUIDUtilities.selector(uuid)); } public void tellraw (Component message, UUID uuid) { tellraw(message, UUIDUtilities.selector(uuid)); }