mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
text limit TextPacket CommandRequestPacket
This commit is contained in:
parent
575c8fd2e3
commit
a9973e7c1f
2 changed files with 27 additions and 3 deletions
|
|
@ -29,6 +29,7 @@ import org.cloudburstmc.protocol.bedrock.packet.CommandRequestPacket;
|
|||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.util.PlatformType;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
|
|
@ -38,7 +39,14 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
|
|||
|
||||
@Override
|
||||
public void translate(GeyserSession session, CommandRequestPacket packet) {
|
||||
String command = MessageTranslator.convertToPlainText(packet.getCommand());
|
||||
String command = packet.getCommand();
|
||||
if (command.length() > 512) {
|
||||
// A legitimate player cannot send more than 512 characters
|
||||
// This is necessary so that the conversion to plain text is not clogged
|
||||
session.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.chat.too_long", session.locale(), command.length()));
|
||||
return;
|
||||
}
|
||||
command = MessageTranslator.convertToPlainText(packet.getCommand());
|
||||
handleCommand(session, MessageTranslator.normalizeSpace(command).substring(1));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.translator.protocol.bedrock;
|
|||
|
||||
import org.cloudburstmc.protocol.bedrock.packet.TextPacket;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
|
|
@ -36,9 +37,24 @@ public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
|
|||
|
||||
@Override
|
||||
public void translate(GeyserSession session, TextPacket packet) {
|
||||
if (!(packet.getParameters().isEmpty())) {
|
||||
// I don't know if the client sends something there on 1.1.5, the client doesn't send anything like that
|
||||
// Add yourself for this text if you need it
|
||||
session.disconnect(GeyserLocale.getPlayerLocaleString("geyser.chat.parameters", session.locale(), packet.getParameters().size()));
|
||||
return;
|
||||
}
|
||||
|
||||
String message = packet.getMessage();
|
||||
if (message.length() > 512) {
|
||||
// A legitimate player cannot send more than 512 characters
|
||||
// This is necessary so that the conversion to plain text is not clogged
|
||||
session.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.chat.too_long", session.locale(), message.length()));
|
||||
return;
|
||||
}
|
||||
|
||||
// Java trims all messages, and then checks for the leading slash
|
||||
String message = MessageTranslator.convertToPlainText(
|
||||
MessageTranslator.normalizeSpace(packet.getMessage())
|
||||
message = MessageTranslator.convertToPlainText(
|
||||
MessageTranslator.normalizeSpace(message)
|
||||
);
|
||||
|
||||
if (message.isBlank()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue