001 package org.bukkit.inventory.meta; 002 003 import java.util.List; 004 005 import org.bukkit.Material; 006 007 /** 008 * Represents a book ({@link Material#BOOK_AND_QUILL} or {@link 009 * Material#WRITTEN_BOOK}) that can have a title, an author, and pages. 010 */ 011 public interface BookMeta extends ItemMeta { 012 013 /** 014 * Checks for the existence of a title in the book. 015 * 016 * @return true if the book has a title 017 */ 018 boolean hasTitle(); 019 020 /** 021 * Gets the title of the book. 022 * <p> 023 * Plugins should check that hasTitle() returns true before calling this 024 * method. 025 * 026 * @return the title of the book 027 */ 028 String getTitle(); 029 030 /** 031 * Sets the title of the book. 032 * <p> 033 * Limited to 16 characters. Removes title when given null. 034 * 035 * @param title the title to set 036 * @return true if the title was successfully set 037 */ 038 boolean setTitle(String title); 039 040 /** 041 * Checks for the existence of an author in the book. 042 * 043 * @return the author of the book 044 */ 045 boolean hasAuthor(); 046 047 /** 048 * Gets the author of the book. 049 * <p> 050 * Plugins should check that hasAuthor() returns true before calling this 051 * method. 052 * 053 * @return the author of the book 054 */ 055 String getAuthor(); 056 057 /** 058 * Sets the author of the book. Removes author when given null. 059 * 060 * @param author the author of the book 061 */ 062 void setAuthor(String author); 063 064 /** 065 * Checks for the existence of pages in the book. 066 * 067 * @return true if the book has pages 068 */ 069 boolean hasPages(); 070 071 /** 072 * Gets the specified page in the book. The given page must exist. 073 * 074 * @param page the page number to get 075 * @return the page from the book 076 */ 077 String getPage(int page); 078 079 /** 080 * Sets the specified page in the book. Pages of the book must be 081 * contiguous. 082 * <p> 083 * The data can be up to 256 characters in length, additional characters 084 * are truncated. 085 * 086 * @param page the page number to set 087 * @param data the data to set for that page 088 */ 089 void setPage(int page, String data); 090 091 /** 092 * Gets all the pages in the book. 093 * 094 * @return list of all the pages in the book 095 */ 096 List<String> getPages(); 097 098 /** 099 * Clears the existing book pages, and sets the book to use the provided 100 * pages. Maximum 50 pages with 256 characters per page. 101 * 102 * @param pages A list of pages to set the book to use 103 */ 104 void setPages(List<String> pages); 105 106 /** 107 * Clears the existing book pages, and sets the book to use the provided 108 * pages. Maximum 50 pages with 256 characters per page. 109 * 110 * @param pages A list of strings, each being a page 111 */ 112 void setPages(String... pages); 113 114 /** 115 * Adds new pages to the end of the book. Up to a maximum of 50 pages with 116 * 256 characters per page. 117 * 118 * @param pages A list of strings, each being a page 119 */ 120 void addPage(String... pages); 121 122 /** 123 * Gets the number of pages in the book. 124 * 125 * @return the number of pages in the book 126 */ 127 int getPageCount(); 128 129 BookMeta clone(); 130 }