Solved Book titles.

Discussion in 'Plugin Help/Development/Requests' started by metmad22, Apr 5, 2015.

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

    metmad22

    Hello community, I've been trying to add some code to my plugin that lets me check if a book has a title. If it does, I want it to send a message to a player the book's title, page number and text inside if the player has a permission. If the book is not signed (does not have a title), simply send a message saying bookTitle = null, page count and text. Here is what I have so far.

    *No, it's not working. No, there are no errors at all.*

    Code:
       public void onBookLog(PlayerEditBookEvent event)
        {
            Player player = event.getPlayer();
     
      if (!player.hasPermission("book.getText")) return;
     
            try
            {
       String bookTitle = "UNSIGNED";
       if(event.isSigning())
       {
        bookTitle = (event.getNewBookMeta().hasTitle()) ?
         event.getNewBookMeta().getTitle().toString() :
         "EMPTY";
       }
      
                player.sendMessage("[TITLE]" + bookTitle + " [PAGES]" + event.getNewBookMeta().getPageCount() + " [TEXT]" + Arrays.toString(event.getNewBookMeta().getPages().toArray()).replaceAll("(Â?§0\\n?|\\s+)+", " ")
            }
            catch (Exception e) { e.printStackTrace(); }
        }


    I forgot the @EventHandler. Sometimes coding a lot can lead to stupid mistakes. Issue solved.
     
    Last edited by a moderator: Apr 6, 2015
Thread Status:
Not open for further replies.

Share This Page