Solved Not able to create and open a book

Discussion in 'Spigot Plugin Development' started by JoshC, Mar 11, 2020.

  1. Hi,

    I'm making a plugin which makes use of a custom book with clickable interface. So before starting I went to look on the docs of spigot and found the following for org.bukkit.entity.player : void openBook(@NotNull ItemStack book). So I went to my IDE and tried it out except for the fact that the player instance doesn't seem to contain this method: "Cannot resolve method 'openBook' in 'Player'". The codeI used was this:
    Code (Java):
    But after searching around on the forums I couldn't find anything related to this issue. I did find that some people still use packages which are sent to the player.

    So I wanted to do the same but first I wanted to create a test custom book in code via BookMeta. So by following the example code I found:
    Code (Java):
    ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
                BookMeta bookMeta = (BookMeta) book.getItemMeta();

                BaseComponent[] page = new ComponentBuilder("Click me")
                        .event(new ClickEvent(ClickEvent.Action.OPEN_URL, ""))
                        .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Go to the spigot website!").create()))

                //add the page to the meta

                //set the title and author of this book
                bookMeta.setTitle("Module editor");

    First part works fine except for the fact of bookMeta.spigot(). I got the error that this method cannot be resolved. So I went to the 1.15.2 snapshot api and in the docs I found out that it should exist. Could someone clarify what I'm doing wrong? Because this is the second time a method doesn't work which is described in the docs.


    Kind regards,

    Another side note. I use IntelliJ IDE with maven and included the followping dependency (ofcourse with the corresponding repository):
    Code (Text):
    #1 JoshC, Mar 11, 2020
    Last edited: Mar 11, 2020
  2. Not true, you just need to use the Spigot API instead of Bukkit.

    OP, try updating Maven indices first (Maven -> Reimport), it's possible IJ just hasn't updated. If that fails, make sure you don't have an outdated version of Bukkit, Spigot, or CB earlier in your dependencies (including those provided by other dependencies!) than spigot-api. Maven's dependency tree can be useful for tracking down issues like that.

    Edit: if you're having trouble still and need to check if it's maven or IJ bugging out, ignore the issue and run package or install and see if Maven can compile successfully. If yes, it's IJ, if no, it's an issue with your dependency ordering.
  3. Thank you for your post. I've reimported the libraries but that didn't work sadly. I also tried to package it but without succes... I currently use the
    1.15.2-R0.1-SNAPSHOT of the spigot maven. Is there any newer version to be found?
  4. Good, we know it's Maven and not IJ then. That should be the latest. Did you check your dependency tree? Please post your pom if you're still having issues.
  5. Hi, sorry for late reply. Here is my pom:
    Code (Java):
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns=""





  6. Move spigot-api above worldedit-bukkit in your dependency list. If that still doesn't solve the issue, please post the output of mvn
    -e -X dependency:tree
    so we can figure out exactly what exclusions you need to add to WE.
  7. Oh wow that solved the issue. How come that by moving it up solved such an issue? Is it related to the WE api?
  8. Yes. That's why I kept asking you to run maven's dependency tree - if you had, you'd see that WE depends on an earlier version of Bukkit, which is then provided by Maven when compiling, which is overriding the BookMeta provided by Spigot-API.

    Edit: accidentally a wrong class
  9. Ahh okay! Thanks a lot for your help! Very happy with this.