3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-25 15:50:14 +01:00
Dieser Commit ist enthalten in:
AJ Ferguson 2024-04-30 04:45:07 -04:00
Ursprung c963503fef
Commit dacacc6df8
4 geänderte Dateien mit 13 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.geyser.inventory; package org.geysermc.geyser.inventory;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.protocol.data.game.inventory.ContainerType; import org.geysermc.mcprotocollib.protocol.data.game.inventory.ContainerType;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundRenameItemPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundRenameItemPacket;
import lombok.Getter; import lombok.Getter;
@ -72,10 +73,9 @@ public class AnvilContainer extends Container {
String correctRename; String correctRename;
newName = rename; newName = rename;
// TODO 1.20.5 fix properly - this name is apparently nullable?? Component originalName = ItemUtils.getCustomName(getInput().getComponents());
String originalName = MessageTranslator.convertMessage(ItemUtils.getCustomName(getInput().getComponents()));
String plainOriginalName = MessageTranslator.convertToPlainTextLenient(originalName, session.locale()); String plainOriginalName = MessageTranslator.convertToPlainText(originalName, session.locale());
String plainNewName = MessageTranslator.convertToPlainText(rename); String plainNewName = MessageTranslator.convertToPlainText(rename);
if (!plainOriginalName.equals(plainNewName)) { if (!plainOriginalName.equals(plainNewName)) {
// Strip out formatting since Java Edition does not allow it // Strip out formatting since Java Edition does not allow it
@ -85,7 +85,7 @@ public class AnvilContainer extends Container {
session.sendDownstreamGamePacket(renameItemPacket); session.sendDownstreamGamePacket(renameItemPacket);
} else { } else {
// Restore formatting for item since we're not renaming // Restore formatting for item since we're not renaming
correctRename = MessageTranslator.convertMessageLenient(originalName); correctRename = MessageTranslator.convertMessage(originalName, session.locale());
// Java Edition sends the original custom name when not renaming, // Java Edition sends the original custom name when not renaming,
// if there isn't a custom name an empty string is sent // if there isn't a custom name an empty string is sent
ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(plainOriginalName); ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(plainOriginalName);

Datei anzeigen

@ -118,8 +118,7 @@ public class AnvilInventoryUpdater extends InventoryUpdater {
// Changing the item in the input slot resets the name field on Bedrock, but // Changing the item in the input slot resets the name field on Bedrock, but
// does not result in a FilterTextPacket // does not result in a FilterTextPacket
// TODO test String originalName = MessageTranslator.convertToPlainText(ItemUtils.getCustomName(input.getComponents()), session.locale());
String originalName = MessageTranslator.convertToPlainText(ItemUtils.getCustomName(input.getComponents()));
ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(originalName); ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(originalName);
session.sendDownstreamGamePacket(renameItemPacket); session.sendDownstreamGamePacket(renameItemPacket);

Datei anzeigen

@ -260,13 +260,17 @@ public class MessageTranslator {
} }
/** /**
* Convert legacy format message to plain text * Convert a Java message to plain text
* *
* @param message Message to convert * @param message Message to convert
* @param locale Locale to use for translation strings
* @return The plain text of the message * @return The plain text of the message
*/ */
public static String convertToPlainText(Component message) { public static String convertToPlainText(Component message, String locale) {
return PlainTextComponentSerializer.plainText().serialize(message); if (message == null) {
return "";
}
return PlainTextComponentSerializer.plainText().serialize(RENDERER.render(message, locale));
} }
/** /**

Datei anzeigen

@ -15,7 +15,7 @@ protocol-connection = "3.0.0.Beta1-20240411.165033-128"
raknet = "1.0.0.CR3-20240416.144209-1" raknet = "1.0.0.CR3-20240416.144209-1"
blockstateupdater="1.20.80-20240411.142413-1" blockstateupdater="1.20.80-20240411.142413-1"
mcauthlib = "d9d773e" mcauthlib = "d9d773e"
mcprotocollib = "400f1b4" # Revert from jitpack after release mcprotocollib = "bc8526b" # Revert from jitpack after release
adventure = "4.14.0" adventure = "4.14.0"
adventure-platform = "4.3.0" adventure-platform = "4.3.0"
junit = "5.9.2" junit = "5.9.2"