Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6911

Change max book length in CraftMetaBook

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • 1.18.1-R0.1-SNAPSHOT
    • Yes

      When creating a written book, there is a limit to how many characters there can be used on each page.

      This is set in CraftMetaBook:

      static final int MAX_PAGE_LENGTH = 320; // 256 limit + 64 characters to allow for psuedo colour codes

      It is possible to create a written book with more than 320 characters. Therefore I think this should be removed.

      The issue can be reproduced like this:

      ItemStack item = new ItemStack(Material.WRITTEN_BOOK);
          BookMeta meta = (BookMeta) item.getItemMeta();
          meta.setTitle("Title");
          meta.setAuthor("Author");
         
          String[] pages = new String[] {
          ".............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................."
          };
         
          meta.setPages(pages);
          item.setItemMeta(meta);
         
          p.openBook(item); 

      Note: There are 798 dots in the example.

      This will create a book and open it for the player, but the book will only be half-filled with dots. If you copy the text and paste it into a book and quill, it will fill the whole book with dots, without any problems - signing it will work as well.

            Unassigned Unassigned
            thorvaldemar Thor Bilsby
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: