Fix writable book (#478)

This commit is contained in:
EpicPlayerA10 2021-10-08 22:24:01 +02:00 committed by GitHub
parent 11806b9166
commit 6e16fb7b13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
package net.minestom.server.item.metadata; package net.minestom.server.item.metadata;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.minestom.server.item.ItemMeta; import net.minestom.server.item.ItemMeta;
import net.minestom.server.item.ItemMetaBuilder; import net.minestom.server.item.ItemMetaBuilder;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -70,7 +70,7 @@ public class WritableBookMeta extends ItemMeta implements ItemMetaBuilder.Provid
handleCollection(pages, "pages", () -> { handleCollection(pages, "pages", () -> {
NBTList<NBTString> list = new NBTList<>(NBTTypes.TAG_String); NBTList<NBTString> list = new NBTList<>(NBTTypes.TAG_String);
for (Component page : pages) { for (Component page : pages) {
list.add(new NBTString(GsonComponentSerializer.gson().serialize(page))); list.add(new NBTString(LegacyComponentSerializer.legacyAmpersand().serialize(page)));
} }
return list; return list;
}); });
@ -94,7 +94,7 @@ public class WritableBookMeta extends ItemMeta implements ItemMetaBuilder.Provid
if (nbtCompound.containsKey("pages")) { if (nbtCompound.containsKey("pages")) {
final NBTList<NBTString> list = nbtCompound.getList("pages"); final NBTList<NBTString> list = nbtCompound.getList("pages");
for (NBTString page : list) { for (NBTString page : list) {
this.pages.add(GsonComponentSerializer.gson().deserialize(page.getValue())); this.pages.add(LegacyComponentSerializer.legacyAmpersand().deserialize(page.getValue()));
} }
pages(pages); pages(pages);
} }