Solved Code stopped working

Discussion in 'Plugin Development' started by chrisman0091, Jan 6, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    chrisman0091

    So I'm working on some code for a book given on join, and everything works fine but suddenly the book is just a Written Book(un-editable), blank. All I've changed is the content of the pages, and I tried commenting them out and using blank pages with no luck.

    Code:
    Code:java
    1. static ItemStack jb = new ItemStack(Material.WRITTEN_BOOK, 1);{
    2. BookMeta bm = (BookMeta) jb.getItemMeta();
    3. bm.addPage("1", "2", "3", "4", "5", "6");
    4. bm.setPage(1, (ChatColor.DARK_RED + "Welcome to BukkitMC!" + "\n" + "\n" +
    5. ChatColor.BLACK + "Here at BukkitMC your experience and enjoyment is #1. We strive to make a fun, " +
    6. "active server for you to love. This book will give you all the" +
    7. "information you need to get started and know your way around the server!"));
    8.  
    9. bm.setPage(2, ("§4Rules and Guidelines\n\n§01. No hacking/modding\n2. No racism or hate speech\n3. " +
    10. "No sharing illegal content in chat\n4. No posting any sort of DOX\n5. No advertising AT ALL\n\n " +
    11. "More in-depth at <Edit by Moderator: Redacted bit url>
    12.  
    13. bm.setPage(3, "§3Chat &0 || §4Ranks\n§3[] §0= Staff\n§6[] §0= Donator\n§7[] §0= Regular Memeber");
    14.  
    15. bm.setPage(4, ("§4Staff\n\n§0Admin: petercraig\nAdmin: chrisman0091"));
    16.  
    17. bm.setPage(5, ("§2Plugin §0|| §4FastPath\n\n§0Tired of taking forever to get down a stripmine? " +
    18. "Not anymore! Putting sponges down will give anybody who walks on it a speed buff as long as they " +
    19. "are on it! Only donators can place sand, though anybody can raid it, so be careful!"));
    20.  
    21. bm.setAuthor(ChatColor.GREEN + "BukkitMC");
    22. bm.setDisplayName(ChatColor.DARK_RED + "Read me!");
    23.  
    24. jb.setItemMeta(bm);
    25. }


    Any idea?
     
    Last edited by a moderator: Feb 14, 2017
  2. Try removing the 6
     
  3. Offline

    chrisman0091

    Didn't fix it.
     
  4. Offline

    Atakyn

    You want to initialize static variables in a static block
    Code:java
    1. static ItemStack jb = new ItemStack(Material.WRITTEN_BOOK, 1);
    2. static {
    3. //Code here
    4. }
     
  5. Offline

    chrisman0091

    That fixed it! I don't know why it worked without it before. Oh well, thanks so much for the help!
     
Thread Status:
Not open for further replies.

Share This Page