mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-05 18:32:28 +01:00
Fix item names and lore
This commit is contained in:
parent
4ba85b4ff3
commit
6d45dc674d
@ -120,7 +120,11 @@ public class NbtReaderUtils {
|
||||
String stringName = reader.readShortSizedString();
|
||||
|
||||
if (stringName.equals("Name")) {
|
||||
item.setDisplayName(reader.readShortSizedString());
|
||||
String jsonDisplayName = reader.readShortSizedString();
|
||||
Component textObject = Chat.fromJsonString(jsonDisplayName);
|
||||
String displayName = Chat.toLegacyText(textObject);
|
||||
|
||||
item.setDisplayName(displayName);
|
||||
readItemStackDisplayNBT(reader, item);
|
||||
}
|
||||
break;
|
||||
@ -134,7 +138,11 @@ public class NbtReaderUtils {
|
||||
int size = reader.readInteger();
|
||||
ArrayList<String> lore = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
lore.add(reader.readShortSizedString());
|
||||
String string = reader.readShortSizedString();
|
||||
Component textObject = Chat.fromJsonString(string);
|
||||
String line = Chat.toLegacyText(textObject);
|
||||
|
||||
lore.add(line);
|
||||
if (lore.size() == size) {
|
||||
item.setLore(lore);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class Utils {
|
||||
if (hasDisplayName) {
|
||||
packet.writeByte((byte) 0x08);
|
||||
packet.writeShortSizedString("Name");
|
||||
packet.writeShortSizedString(itemStack.getDisplayName());
|
||||
packet.writeShortSizedString(Chat.toJsonString(Chat.fromLegacyText(itemStack.getDisplayName())));
|
||||
}
|
||||
|
||||
if (hasLore) {
|
||||
@ -128,7 +128,7 @@ public class Utils {
|
||||
packet.writeByte((byte) 0x08);
|
||||
packet.writeInt(lore.size());
|
||||
for (String line : lore) {
|
||||
packet.writeShortSizedString(line);
|
||||
packet.writeShortSizedString(Chat.toJsonString(Chat.fromLegacyText(line)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user