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

This commit is contained in:
Camotoy 2022-04-18 21:30:44 -04:00
parent 67f4de9781
commit af08488d1e
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
1 changed files with 7 additions and 5 deletions

View File

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