mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 13:08:19 +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();
|
String stringName = reader.readShortSizedString();
|
||||||
|
|
||||||
if (stringName.equals("Name")) {
|
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);
|
readItemStackDisplayNBT(reader, item);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -134,7 +138,11 @@ public class NbtReaderUtils {
|
|||||||
int size = reader.readInteger();
|
int size = reader.readInteger();
|
||||||
ArrayList<String> lore = new ArrayList<>(size);
|
ArrayList<String> lore = new ArrayList<>(size);
|
||||||
for (int i = 0; i < size; i++) {
|
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) {
|
if (lore.size() == size) {
|
||||||
item.setLore(lore);
|
item.setLore(lore);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class Utils {
|
|||||||
if (hasDisplayName) {
|
if (hasDisplayName) {
|
||||||
packet.writeByte((byte) 0x08);
|
packet.writeByte((byte) 0x08);
|
||||||
packet.writeShortSizedString("Name");
|
packet.writeShortSizedString("Name");
|
||||||
packet.writeShortSizedString(itemStack.getDisplayName());
|
packet.writeShortSizedString(Chat.toJsonString(Chat.fromLegacyText(itemStack.getDisplayName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasLore) {
|
if (hasLore) {
|
||||||
@ -128,7 +128,7 @@ public class Utils {
|
|||||||
packet.writeByte((byte) 0x08);
|
packet.writeByte((byte) 0x08);
|
||||||
packet.writeInt(lore.size());
|
packet.writeInt(lore.size());
|
||||||
for (String line : lore) {
|
for (String line : lore) {
|
||||||
packet.writeShortSizedString(line);
|
packet.writeShortSizedString(Chat.toJsonString(Chat.fromLegacyText(line)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user