Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Replace § in sign text and book editing operations (#3721)
Dieser Commit ist enthalten in:
Ursprung
baae46822e
Commit
4d929f8a2c
@ -34,6 +34,7 @@ import org.geysermc.geyser.network.GameProtocol;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
import org.geysermc.geyser.util.SignUtils;
|
||||
|
||||
@Translator(packet = BlockEntityDataPacket.class)
|
||||
@ -52,6 +53,7 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
|
||||
} else {
|
||||
text = tag.getString("Text");
|
||||
}
|
||||
text = MessageTranslator.convertToPlainText(text);
|
||||
// Note: as of 1.18.30, only one packet is sent from Bedrock when the sign is finished.
|
||||
// Previous versions did not have this behavior.
|
||||
StringBuilder newMessage = new StringBuilder();
|
||||
|
@ -36,6 +36,7 @@ import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
@ -68,19 +69,19 @@ public class BedrockBookEditTranslator extends PacketTranslator<BookEditPacket>
|
||||
for (int i = pages.size(); i < page; i++) {
|
||||
pages.add(i, new StringTag("", ""));
|
||||
}
|
||||
pages.add(page, new StringTag("", packet.getText()));
|
||||
pages.add(page, new StringTag("", MessageTranslator.convertToPlainText(packet.getText())));
|
||||
break;
|
||||
}
|
||||
// Called whenever a page is modified
|
||||
case REPLACE_PAGE: {
|
||||
if (page < pages.size()) {
|
||||
pages.set(page, new StringTag("", packet.getText()));
|
||||
pages.set(page, new StringTag("", MessageTranslator.convertToPlainText(packet.getText())));
|
||||
} else {
|
||||
// Add empty pages in between
|
||||
for (int i = pages.size(); i < page; i++) {
|
||||
pages.add(i, new StringTag("", ""));
|
||||
}
|
||||
pages.add(page, new StringTag("", packet.getText()));
|
||||
pages.add(page, new StringTag("", MessageTranslator.convertToPlainText(packet.getText())));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -98,8 +99,8 @@ public class BedrockBookEditTranslator extends PacketTranslator<BookEditPacket>
|
||||
break;
|
||||
}
|
||||
case SIGN_BOOK: {
|
||||
tag.put(new StringTag("author", packet.getAuthor()));
|
||||
tag.put(new StringTag("title", packet.getTitle()));
|
||||
tag.put(new StringTag("author", MessageTranslator.convertToPlainText(packet.getAuthor())));
|
||||
tag.put(new StringTag("title", MessageTranslator.convertToPlainText(packet.getTitle())));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -127,12 +128,11 @@ public class BedrockBookEditTranslator extends PacketTranslator<BookEditPacket>
|
||||
String title;
|
||||
if (packet.getAction() == BookEditPacket.Action.SIGN_BOOK) {
|
||||
// Add title to packet so the server knows we're signing
|
||||
if (packet.getTitle().getBytes(StandardCharsets.UTF_8).length > MAXIMUM_TITLE_LENGTH) {
|
||||
title = MessageTranslator.convertToPlainText(packet.getTitle());
|
||||
if (title.getBytes(StandardCharsets.UTF_8).length > MAXIMUM_TITLE_LENGTH) {
|
||||
session.getGeyser().getLogger().warning("Book title larger than server allows!");
|
||||
return;
|
||||
}
|
||||
|
||||
title = packet.getTitle();
|
||||
} else {
|
||||
title = null;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren