Don't let Bedrock players send format character
See
@@ -28,6 +28,7 @@ package org.geysermc.geyser.translator.protocol.bedrock;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import com.nukkitx.protocol.bedrock.packet.TextPacket;
import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.translator.text.MessageTranslator;
@@ -44,6 +45,18 @@ public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
return;
}
+ if (message.indexOf(ChatColor.ESCAPE) != -1) {
+ // Filter out all escape characters - Java doesn't let you type these
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < message.length(); i++) {
+ char c = message.charAt(i);
+ if (c != ChatColor.ESCAPE) {
+ builder.append(c);
+ }
+ }
+ message = builder.toString();
+ }
+
if (MessageTranslator.isTooLong(message, session)) {
return;
}
