Skip to content

Commit

Permalink
Fixed reading and writing of book pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Twillen committed Apr 28, 2013
1 parent c360e93 commit 6bd0cb7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/net/citizensnpcs/api/util/ItemStorage.java
Expand Up @@ -77,9 +77,8 @@ private static void deserialiseMeta(DataKey root, ItemStack res) {
}
if (root.keyExists("book")) {
BookMeta meta = ensureMeta(res);
int i = 0;
for (DataKey sub : root.getRelative("book.pages").getIntegerSubKeys()) {
meta.setPage(i, sub.getString(""));
meta.addPage(sub.getString(""));
}
meta.setTitle(root.getString("book.title"));
meta.setAuthor(root.getString("book.author"));
Expand Down Expand Up @@ -209,7 +208,7 @@ private static void serialiseMeta(DataKey key, ItemMeta meta) {
if (meta instanceof BookMeta) {
BookMeta book = (BookMeta) meta;
DataKey pages = key.getRelative("book.pages");
for (int i = 0; i < book.getPageCount(); i++) {
for (int i = 1; i <= book.getPageCount(); i++) {
pages.setString(Integer.toString(i), book.getPage(i));
}
key.setString("book.title", book.getTitle());
Expand Down

0 comments on commit 6bd0cb7

Please sign in to comment.