forked from GeyserMC/Geyser
Added warning message if chat message is longer than 256 characters.
This commit is contained in:
parent
e67ed6dc8d
commit
79a7258fd1
2 changed files with 24 additions and 3 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue