diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java index 9dabc62..31c0025 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java @@ -73,7 +73,7 @@ public class CommandCopy implements TabExecutor { } BookMeta bookMeta = (BookMeta) heldBook.getItemMeta(); - if (BooksWithoutBordersConfig.changeGenerationOnCopy() && bookMeta != null && bookMeta.hasGeneration()) { + if (BooksWithoutBordersConfig.changeGenerationOnCopy() && bookMeta != null) { return copyNextGenerationBook(bookMeta, player, copies); } else { //Make sure the player can pay for the copying diff --git a/src/main/java/net/knarcraft/bookswithoutborders/config/ConfigOption.java b/src/main/java/net/knarcraft/bookswithoutborders/config/ConfigOption.java index 7fc0603..23eba32 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/config/ConfigOption.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/config/ConfigOption.java @@ -63,7 +63,7 @@ public enum ConfigOption { /** * Whether to turn Original into Copy when copying books */ - CHANGE_GENERATION_ON_COPY("Options.Decrease_Generation_On_Copy", false), + CHANGE_GENERATION_ON_COPY("Options.Change_Generation_On_Copy", false), /** * Whether to automatically format every signed book diff --git a/src/main/java/net/knarcraft/bookswithoutborders/utility/BookHelper.java b/src/main/java/net/knarcraft/bookswithoutborders/utility/BookHelper.java index 84451bd..b74c1fb 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/utility/BookHelper.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/utility/BookHelper.java @@ -25,7 +25,7 @@ public final class BookHelper { */ public static void increaseGeneration(ItemStack bookItem) { BookMeta bookMeta = (BookMeta) bookItem.getItemMeta(); - if (BooksWithoutBordersConfig.changeGenerationOnCopy() && bookMeta != null && bookMeta.hasGeneration()) { + if (BooksWithoutBordersConfig.changeGenerationOnCopy() && bookMeta != null) { bookMeta.setGeneration(BookHelper.getNextGeneration(bookMeta.getGeneration())); bookItem.setItemMeta(bookMeta); } @@ -41,6 +41,9 @@ public final class BookHelper { * @return
The next generation of the book
*/ public static BookMeta.Generation getNextGeneration(BookMeta.Generation currentGeneration) { + if (currentGeneration == null) { + return BookMeta.Generation.COPY_OF_ORIGINAL; + } return switch (currentGeneration) { case ORIGINAL -> BookMeta.Generation.COPY_OF_ORIGINAL; case COPY_OF_ORIGINAL -> BookMeta.Generation.COPY_OF_COPY; diff --git a/src/main/java/net/knarcraft/bookswithoutborders/utility/BookLoader.java b/src/main/java/net/knarcraft/bookswithoutborders/utility/BookLoader.java index 65060ee..dbdbe45 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/utility/BookLoader.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/utility/BookLoader.java @@ -64,7 +64,7 @@ public final class BookLoader { } //Make sure the player can pay for the book - if (BooksWithoutBordersConfig.booksHavePrice() && + if (BooksWithoutBordersConfig.booksHavePrice() && !sender.hasPermission("bookswithoutborders.bypassBookPrice") && (bookDirectory == BookDirectory.PUBLIC || bookDirectory == BookDirectory.PLAYER) && EconomyHelper.cannotPayForBookPrinting((Player) sender, numCopies)) { diff --git a/src/main/java/net/knarcraft/bookswithoutborders/utility/BookToFromTextHelper.java b/src/main/java/net/knarcraft/bookswithoutborders/utility/BookToFromTextHelper.java index 987ea1d..262eaf1 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/utility/BookToFromTextHelper.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/utility/BookToFromTextHelper.java @@ -41,9 +41,11 @@ public final class BookToFromTextHelper { if (bookMetadata.hasAuthor()) { bookYml.set("Author", bookMetadata.getAuthor()); } - if (bookMetadata.hasGeneration() && bookMetadata.getGeneration() != null) { - bookYml.set("Generation", bookMetadata.getGeneration().name()); + BookMeta.Generation generation = bookMetadata.getGeneration(); + if (generation == null) { + generation = BookMeta.Generation.ORIGINAL; } + bookYml.set("Generation", generation.name()); if (bookMetadata.hasPages()) { bookYml.set("Pages", bookMetadata.getPages()); } @@ -84,15 +86,14 @@ public final class BookToFromTextHelper { PrintWriter printWriter = new PrintWriter(fileWriter); List