Moves book to text code to its own class, and moves lots of encryption code to the encryption helper

This commit is contained in:
2021-09-01 23:02:54 +02:00
parent 8defb301bc
commit 1ddd50e5df
6 changed files with 471 additions and 386 deletions

View File

@@ -71,7 +71,7 @@ public class CommandDecrypt implements CommandExecutor {
if (!key.equalsIgnoreCase("")) {
//Decrypt the book
ItemStack book = booksWithoutBorders.loadEncryptedBook(player, key, false);
ItemStack book = EncryptionHelper.loadEncryptedBook(player, key, false);
if (book != null) {
InventoryHelper.setHeldWrittenBook(player, book);
BooksWithoutBorders.sendSuccessMessage(player, "Book auto-decrypted!");
@@ -91,7 +91,7 @@ public class CommandDecrypt implements CommandExecutor {
String key = EncryptionHelper.getNumberKeyFromStringKey(args[0]);
//Decrypt the book
ItemStack book = booksWithoutBorders.loadEncryptedBook(player, key, true);
ItemStack book = EncryptionHelper.loadEncryptedBook(player, key, true);
if (book != null) {
InventoryHelper.setHeldWrittenBook(player, book);
BooksWithoutBorders.sendSuccessMessage(player, "Book decrypted!");

View File

@@ -2,6 +2,7 @@ package net.knarcraft.bookswithoutborders.command;
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
import net.knarcraft.bookswithoutborders.state.EncryptionStyle;
import net.knarcraft.bookswithoutborders.utility.EncryptionHelper;
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -83,7 +84,7 @@ public class CommandEncrypt implements CommandExecutor {
* @return <p>True if the book was encrypted successfully</p>
*/
boolean encryptBook(EncryptionStyle encryptionStyle, Player player, String key, String group) {
ItemStack encryptedBook = booksWithoutBorders.encryptBook(player, true, key, encryptionStyle, group);
ItemStack encryptedBook = EncryptionHelper.encryptBook(player, true, key, encryptionStyle, group);
if (encryptedBook != null) {
InventoryHelper.setHeldWrittenBook(player, encryptedBook);