3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Added warning message if chat message is longer than 256 characters.

Dieser Commit ist enthalten in:
rtm516 2020-04-13 11:10:53 +01:00
Ursprung e67ed6dc8d
Commit 79a7258fd1
2 geänderte Dateien mit 24 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -45,7 +45,14 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
if (session.getConnector().getPlatformType() == PlatformType.STANDALONE && command.startsWith("geyser ") && commandMap.getCommands().containsKey(command.split(" ")[1])) { if (session.getConnector().getPlatformType() == PlatformType.STANDALONE && command.startsWith("geyser ") && commandMap.getCommands().containsKey(command.split(" ")[1])) {
commandMap.runCommand(session, command); commandMap.runCommand(session, command);
} else { } else {
ClientChatPacket chatPacket = new ClientChatPacket(packet.getCommand()); String message = packet.getCommand().trim();
if (message.length() > 256) {
session.sendMessage("Your message is bigger than 256 characters (" + message.length() + ") so it has not been sent.");
return;
}
ClientChatPacket chatPacket = new ClientChatPacket(message);
session.getDownstream().getSession().send(chatPacket); session.getDownstream().getSession().send(chatPacket);
} }
} }

Datei anzeigen

@ -38,12 +38,26 @@ public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
@Override @Override
public void translate(TextPacket packet, GeyserSession session) { public void translate(TextPacket packet, GeyserSession session) {
if (packet.getMessage().charAt(0) == '.') { if (packet.getMessage().charAt(0) == '.') {
ClientChatPacket chatPacket = new ClientChatPacket(packet.getMessage().replace(".", "/")); String message = packet.getMessage().replace(".", "/").trim();
if (message.length() > 256) {
session.sendMessage("Your message is bigger than 256 characters (" + message.length() + ") so it has not been sent.");
return;
}
ClientChatPacket chatPacket = new ClientChatPacket(message);
session.getDownstream().getSession().send(chatPacket); session.getDownstream().getSession().send(chatPacket);
return; return;
} }
ClientChatPacket chatPacket = new ClientChatPacket(packet.getMessage()); String message = packet.getMessage().trim();
if (message.length() > 256) {
session.sendMessage("Your message is bigger than 256 characters (" + message.length() + ") so it has not been sent.");
return;
}
ClientChatPacket chatPacket = new ClientChatPacket(message);
session.getDownstream().getSession().send(chatPacket); session.getDownstream().getSession().send(chatPacket);
} }
} }