From 1d3c50aab14080a9ba9d1f2c58c2b235cad7637d Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 2 Sep 2021 22:18:15 +0200 Subject: [PATCH] Adds info about the encrypt and decrypt signs, and fixes a bug in group decryption --- README.md | 13 ++++++++++++- .../bookswithoutborders/BooksWithoutBorders.java | 2 +- .../listener/SignEventListener.java | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 961cb85..9830522 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,15 @@ Each plugin sign must have [BwB] on its first line. The **_give_** sign must have **[Give]** on its second line. The third and fourth line contains the book to be loaded. This can either be a numerical id pointing to a publicly saved book, -or the full text identifier of the book (book name, author). \ No newline at end of file +or the full text identifier of the book (book name, author). + +#### Encrypt sign + +The **_encrypt_** sign must have **[Encrypt]** on its second line. +The third line must contain the encryption key +The fourth line can be empty or contain "dna" for dna-based encryption. + +#### Decrypt sign + +The **_decrypt_** sign must have **[Decrypt]** on its second line. +The third line must contain the decryption key \ No newline at end of file diff --git a/src/main/java/net/knarcraft/bookswithoutborders/BooksWithoutBorders.java b/src/main/java/net/knarcraft/bookswithoutborders/BooksWithoutBorders.java index 6c96b85..b91081b 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/BooksWithoutBorders.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/BooksWithoutBorders.java @@ -388,7 +388,7 @@ public class BooksWithoutBorders extends JavaPlugin { file = FileHelper.getBookFile(getBookFolder() + fileName); } else if (dir.equalsIgnoreCase("player")) { file = FileHelper.getBookFile(getBookFolder() + cleanString(sender.getName()) + getSlash() + fileName); - } else if (dir.trim().isEmpty()) { + } else if (!dir.trim().isEmpty()) { file = FileHelper.getBookFile(getBookFolder() + "Encrypted" + getSlash() + dir + getSlash() + fileName); } else { file = null; diff --git a/src/main/java/net/knarcraft/bookswithoutborders/listener/SignEventListener.java b/src/main/java/net/knarcraft/bookswithoutborders/listener/SignEventListener.java index 3b7b667..b61dc82 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/listener/SignEventListener.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/listener/SignEventListener.java @@ -254,6 +254,10 @@ public class SignEventListener implements Listener { } newBook = BooksWithoutBorders.getInstance().loadBook(player, fileName, "true", groupName, heldItem.getAmount()); + if (newBook == null) { + return; + } + player.getInventory().setItem(hand, newBook); player.closeInventory(); player.sendMessage(ChatColor.GREEN + "Book auto-decrypted!");