Yes. You can create a custom Inventory and pass the book as the inventory holder, and save the inventory to the book using a HashMap. When they player runs the command (you can also set up the inventory opening and right-click), you can get the inventory from the HashMap and open it for the player.
You can create custom inventories for anything. Here's an example, with each book having its own inventory: Code: HashMap<ItemStack, Inventory> bookInvs = new HashMap<ItemStack, Inventory>(); // The second argument is how many slots the inventory has, and must be divisible by 9 // The last argument is the title of the inventory, and is displayed at the top of the inventory GUI Inventory bookInv = server.createInventory(null, 9, "Book"); // Assuming book is an existing ItemStack bookInvs.put(book, bookInv); Then, you can retrieve the Inventory like this: Code: // Assuming book is an existing ItemStack that has a registered Inventory bookInvs.get(book);
Have I misinterpreted your question? I'm sorry, after rereading it seems you want to open the text of a written book? EDIT: Sorry. I can look into it for you, but - from what I know - you'll probably need to use a net.minecraft.server class and figure out some obfuscated method to do this.
Sadly, opening books is client-sided Pretty sure this isn't possible. If it is, let me know! I have wanted to do this too. It would be extremely useful for displaying plugin help
so i am thinking of doing something like this too can i even get notified when they open the book? or close the book? i want to make it so they cant keep the book perminently, but i want them to be able to read other peoples books
You could probably find an event or two in the JavaDocs. Still not quite sure about modifying the opened book, though.
The server is definitely notified when the user opens a book: Code:java @EventHandlerpublic void onOpenBook(PlayerInteractEvent event) { ItemStack stack = event.getItem(); // Make sure this is a book if (stack != null && stack.getType() == Material.WRITTEN_BOOK) { getLogger().info("The player has opened " + stack); }} However, I don't think it's possible to determine if a player has closed the book. The client doesn't send any packet at all when this happens. But you could assume the book has been closed when you perform any other action (like moving).