3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-07-03 20:08:08 +02:00

Check the name tag exists for anvil renaming to prevent an NPE (#936)

* Check the name tag exists for anvil renaming to prevent an NPE

* Fix item names being empty if display tag exists with no name
Dieser Commit ist enthalten in:
rtm516 2020-07-11 21:58:12 +01:00 committet von GitHub
Ursprung 7757913c00
Commit 485ba1b8a7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 2 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -136,7 +136,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
CompoundTag tag = item.getNbt();
if (tag != null) {
CompoundTag displayTag = tag.get("display");
if (displayTag != null) {
if (displayTag != null && displayTag.contains("Name")) {
String itemName = displayTag.get("Name").getValue().toString();
TextMessage message = (TextMessage) MessageSerializer.fromString(itemName);
rename = message.getText();

Datei anzeigen

@ -157,7 +157,7 @@ public abstract class ItemTranslator {
NbtMap tag = itemData.getTag();
if (tag != null) {
NbtMap display = tag.getCompound("display");
if (display != null && !display.isEmpty()) {
if (display != null && !display.isEmpty() && display.containsKey("Name")) {
String name = display.getString("Name");
// If its not a message convert it