From 9febb304cb254c65c04e7d33c4cbb84bf4a8363c Mon Sep 17 00:00:00 2001 From: JRoy <10731363+JRoy@users.noreply.github.com> Date: Sat, 22 Feb 2025 22:19:03 -0500 Subject: [PATCH] Fix /book command on 1.20+ Starting with 1.20, there are two different type of book metas, one for writeable and another for written. Since they are different types, the server silently rejects the setItemMeta call. Just copy over the relevant parts to the new meta. --- .../earth2me/essentials/MetaItemStack.java | 9 +++----- .../essentials/commands/Commandbook.java | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java index 68d9cf68ed7..8347c19a391 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java +++ b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java @@ -3,7 +3,6 @@ import com.earth2me.essentials.textreader.BookInput; import com.earth2me.essentials.textreader.BookPager; import com.earth2me.essentials.textreader.IText; -import com.earth2me.essentials.utils.EnumUtil; import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.MaterialUtil; import com.earth2me.essentials.utils.NumberUtil; @@ -217,8 +216,6 @@ public void addStringMeta(final CommandSource sender, final boolean allowUnsafe, return; } - final Material WRITTEN_BOOK = EnumUtil.getMaterial("WRITTEN_BOOK"); - if (split.length > 1 && split[0].equalsIgnoreCase("name") && hasMetaPermission(sender, "name", false, true, ess)) { final String displayName = FormatUtil.replaceFormat(split[1].replaceAll("(? pages = pager.getPages(split[1]); meta.setPages(pages); stack.setItemMeta(meta); - } else if (split.length > 1 && split[0].equalsIgnoreCase("author") && stack.getType() == WRITTEN_BOOK && hasMetaPermission(sender, "author", false, true, ess)) { + } else if (split.length > 1 && split[0].equalsIgnoreCase("author") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "author", false, true, ess)) { final String author = FormatUtil.replaceFormat(split[1]); final BookMeta meta = (BookMeta) stack.getItemMeta(); meta.setAuthor(author); stack.setItemMeta(meta); - } else if (split.length > 1 && split[0].equalsIgnoreCase("title") && stack.getType() == WRITTEN_BOOK && hasMetaPermission(sender, "title", false, true, ess)) { + } else if (split.length > 1 && split[0].equalsIgnoreCase("title") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "title", false, true, ess)) { final String title = FormatUtil.replaceFormat(split[1].replaceAll("(?