diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java index 0a4c0a8..8d2840f 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java @@ -59,7 +59,7 @@ public class CommandDecrypt implements TabExecutor { //Get the "encryption key" from the filename String key = ""; for (String encryptedFile : encryptedFiles) { - if (encryptedFile.contains(BookHelper.getBookFile(bookMetadata, player))) { + if (encryptedFile.contains(BookHelper.getBookFile(bookMetadata, player, true))) { key = encryptedFile.substring(encryptedFile.indexOf("[") + 1, encryptedFile.indexOf("]")); break; } diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSave.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSave.java index 4874d26..06cfebb 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSave.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSave.java @@ -86,7 +86,7 @@ public class CommandSave implements TabExecutor { saveToPublicFolder ? BookDirectory.PUBLIC : BookDirectory.PLAYER, player); //Generate book filename - String fileName = BookHelper.getBookFile(book, player); + String fileName = BookHelper.getBookFile(book, player, saveToPublicFolder); //Make sure the used folders exist File file = new File(savePath); diff --git a/src/main/java/net/knarcraft/bookswithoutborders/utility/BookHelper.java b/src/main/java/net/knarcraft/bookswithoutborders/utility/BookHelper.java index 2d7cb2d..af7cf1f 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/utility/BookHelper.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/utility/BookHelper.java @@ -116,7 +116,7 @@ public final class BookHelper { * @param player
The player trying to do something with the book
* @returnThe book file
*/ - public static String getBookFile(BookMeta book, Player player) { + public static String getBookFile(BookMeta book, Player player, boolean isPublic) { String titleAuthorSeparator = BooksWithoutBordersConfig.getTitleAuthorSeparator(); String bookName; if (book.hasTitle()) { @@ -126,9 +126,11 @@ public final class BookHelper { } String authorName; - if (!book.hasAuthor() || isAuthor(player.getName(), book.getAuthor())) { + if ((!book.hasAuthor() || isAuthor(player.getName(), book.getAuthor())) && !isPublic) { //Store as unique id to account for name changes authorName = player.getUniqueId().toString(); + } else if (!book.hasAuthor()) { + authorName = player.getName(); } else { authorName = book.getAuthor(); } diff --git a/src/main/java/net/knarcraft/bookswithoutborders/utility/EncryptionHelper.java b/src/main/java/net/knarcraft/bookswithoutborders/utility/EncryptionHelper.java index 9eb84d5..632a0c2 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/utility/EncryptionHelper.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/utility/EncryptionHelper.java @@ -198,7 +198,7 @@ public final class EncryptionHelper { return null; } - String fileName = "[" + key + "]" + BookHelper.getBookFile(bookMetadata, player); + String fileName = "[" + key + "]" + BookHelper.getBookFile(bookMetadata, player, true); fileName = fixName(cleanString(fileName), false); File file = new File(path + fileName + ".yml"); @@ -261,7 +261,7 @@ public final class EncryptionHelper { } } //Generate file name - String fileName = BookHelper.getBookFile(bookMetadata, player); + String fileName = BookHelper.getBookFile(bookMetadata, player, true); List