mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
yeet static import, move blank check
This commit is contained in:
parent
0980547da2
commit
5e25da1887
1 changed files with 8 additions and 8 deletions
|
|
@ -31,15 +31,20 @@ import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||||
|
|
||||||
import static org.geysermc.geyser.translator.text.MessageTranslator.normalizeSpace;
|
|
||||||
|
|
||||||
@Translator(packet = TextPacket.class)
|
@Translator(packet = TextPacket.class)
|
||||||
public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
|
public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, TextPacket packet) {
|
public void translate(GeyserSession session, TextPacket packet) {
|
||||||
// Java trims all messages, and then checks for the leading slash
|
// Java trims all messages, and then checks for the leading slash
|
||||||
String message = MessageTranslator.convertToPlainText(normalizeSpace(packet.getMessage()));
|
String message = MessageTranslator.convertToPlainText(
|
||||||
|
MessageTranslator.normalizeSpace(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;
|
||||||
|
}
|
||||||
|
|
||||||
if (message.startsWith("/")) {
|
if (message.startsWith("/")) {
|
||||||
// Yes, Java actually allows whitespaces before commands and will still see those as valid
|
// Yes, Java actually allows whitespaces before commands and will still see those as valid
|
||||||
|
|
@ -47,11 +52,6 @@ public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue