Solved: Can't access member of class

The below code worked fine until the last Paper update. Now I get:
Can’t access member of class org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMetaBook with modifiers “protected”
I know is a coding issue but this has been working for over a year and has not been changed.
In fact, it still works on my Production server which I have not updated to the newer paper due to this issue. Any idea what has happened?

private static List PAGES;
private static ItemStack BOOK;
private static BookMeta BM;

public Constructor()

Constructor.BOOK = new ItemStack(Material.WRITTEN_BOOK, 1);
Constructor.BM = (BookMeta)BOOK.getItemMeta(); ​


public ItemStack CreateBook()


BM.setAuthor(“The Author”);
PAGES = (List) CraftMetaBook.class.getDeclaredField(“pages”).get(BM);

(Add Pages code would be here but on PROD we don’t get this far)


catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex)

LOG.log(Level.SEVERE, “Book not Created. ***”, ex);
return null;​

return BOOK;​


Yes, upstream changed the modifier on the pages field in

Would you be willing to explain how correct my code to work with the changes? Or point me to an example of how to do what create a written book under the new rules? I seem to be able to create the book and add titles and author, I just don’t get how to add pages since the change to paper.

Show you whole code. Formatted readable.

why are you reflecting internals to begin with? just use the API!

1 Like

Thanks for the replies here but this issue has been solved. details on the Spigot forums under Spigot Plugin Development. Thread: Written Book Works on DEV server but not on PROD??
[Solved] - Written Book Works on DEV server but not on PROD??