3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Fix message being sent still if a single escape character is sent

Dieser Commit ist enthalten in:
Camotoy 2022-04-18 21:30:44 -04:00
Ursprung 67f4de9781
Commit af08488d1e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -40,11 +40,8 @@ public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
public void translate(GeyserSession session, TextPacket packet) { public void translate(GeyserSession session, TextPacket packet) {
String message = packet.getMessage(); String message = packet.getMessage();
if (message.isBlank()) { // The order here is important - strip out illegal characters first, then check if it's blank
// Java Edition (as of 1.17.1) just doesn't pass on these messages, so... we won't either! // (in case the message is blank after removing)
return;
}
if (message.indexOf(ChatColor.ESCAPE) != -1) { if (message.indexOf(ChatColor.ESCAPE) != -1) {
// Filter out all escape characters - Java doesn't let you type these // Filter out all escape characters - Java doesn't let you type these
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -57,6 +54,11 @@ public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
message = builder.toString(); message = builder.toString();
} }
if (message.isBlank()) {
// Java Edition (as of 1.17.1) just doesn't pass on these messages, so... we won't either!
return;
}
if (MessageTranslator.isTooLong(message, session)) { if (MessageTranslator.isTooLong(message, session)) {
return; return;
} }