onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
return doTabCompletion(sender, args, false);
}
/**
* Performs the actual tab completion
- * @param sender The sender of the command
- * @param args The arguments given
+ *
+ * @param sender The sender of the command
+ * @param args The arguments given
* @param listPublic Whether to list public files or player files
* @return A list of available choices
*/
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGivePublic.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGivePublic.java
index e0b28aa..39c50db 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGivePublic.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGivePublic.java
@@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
+import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -12,12 +13,12 @@ import java.util.List;
public class CommandGivePublic extends CommandGive implements TabExecutor {
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
return giveBook(sender, args, true, "public");
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return doTabCompletion(sender, args, true);
}
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGroupEncrypt.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGroupEncrypt.java
index 2ea6734..695b88c 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGroupEncrypt.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGroupEncrypt.java
@@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.BookMeta;
+import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -16,7 +17,7 @@ import java.util.List;
public class CommandGroupEncrypt extends CommandEncrypt implements TabExecutor {
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
BookMeta bookMetadata = performPreChecks(sender, args, 2,
"You must specify a group name and key to encrypt a book!");
@@ -36,7 +37,7 @@ public class CommandGroupEncrypt extends CommandEncrypt implements TabExecutor {
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return doTabCompletion(args, true);
}
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandLoad.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandLoad.java
index 39fd8d0..d987be0 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandLoad.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandLoad.java
@@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -21,7 +22,7 @@ public class CommandLoad implements TabExecutor {
private final BooksWithoutBorders booksWithoutBorders = BooksWithoutBorders.getInstance();
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
return loadBook(sender, args, "player", false);
}
@@ -94,14 +95,15 @@ public class CommandLoad implements TabExecutor {
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
return doTabCompletion(sender, args, false);
}
/**
* Performs the actual tab completion
- * @param sender The sender of the command
- * @param args The arguments given
+ *
+ * @param sender The sender of the command
+ * @param args The arguments given
* @param loadPublic Whether to list public files or player files
* @return A list of available choices
*/
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandLoadPublic.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandLoadPublic.java
index 0a1115e..2a756fe 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandLoadPublic.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandLoadPublic.java
@@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
+import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -12,12 +13,12 @@ import java.util.List;
public class CommandLoadPublic extends CommandLoad implements CommandExecutor {
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
return loadBook(sender, args, "public", true);
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return doTabCompletion(sender, args, true);
}
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandReload.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandReload.java
index c1b1211..31fea94 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandReload.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandReload.java
@@ -4,6 +4,7 @@ import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -16,7 +17,7 @@ public class CommandReload implements TabExecutor {
private final BooksWithoutBorders booksWithoutBorders = BooksWithoutBorders.getInstance();
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (booksWithoutBorders.loadConfig()) {
BooksWithoutBorders.sendSuccessMessage(sender, "BooksWithoutBorders configuration reloaded!");
} else {
@@ -27,7 +28,7 @@ public class CommandReload implements TabExecutor {
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
return new ArrayList<>();
}
}
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSave.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSave.java
index 4cb3a02..21d009b 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSave.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSave.java
@@ -11,6 +11,7 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
+import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
@@ -31,7 +32,7 @@ import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.fixN
public class CommandSave implements TabExecutor {
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
return saveHeldBook(sender, args, false);
}
@@ -148,7 +149,7 @@ public class CommandSave implements TabExecutor {
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
return new ArrayList<>();
}
}
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSavePublic.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSavePublic.java
index b02eeae..a818ae1 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSavePublic.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSavePublic.java
@@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
+import org.jetbrains.annotations.NotNull;
/**
* Command executor for the save public command
@@ -10,7 +11,7 @@ import org.bukkit.command.TabExecutor;
public class CommandSavePublic extends CommandSave implements TabExecutor {
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
return saveHeldBook(sender, args, true);
}
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetAuthor.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetAuthor.java
index bae8db6..69c9205 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetAuthor.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetAuthor.java
@@ -9,6 +9,7 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -19,7 +20,7 @@ import java.util.List;
public class CommandSetAuthor implements TabExecutor {
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player player)) {
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
return false;
@@ -49,7 +50,7 @@ public class CommandSetAuthor implements TabExecutor {
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
if (args.length == 1) {
return null;
} else {
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetBookPrice.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetBookPrice.java
index e191a5b..47cdc9d 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetBookPrice.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetBookPrice.java
@@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -22,7 +23,7 @@ public class CommandSetBookPrice implements TabExecutor {
private final BooksWithoutBorders booksWithoutBorders = BooksWithoutBorders.getInstance();
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
//Clear the current price
if (args.length == 0) {
clearItemPrice(sender);
@@ -132,7 +133,7 @@ public class CommandSetBookPrice implements TabExecutor {
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
int argumentCount = args.length;
if (argumentCount == 1) {
List paymentTypes = new ArrayList<>();
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetLore.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetLore.java
index 2f27996..a2f481f 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetLore.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetLore.java
@@ -10,6 +10,7 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
@@ -21,7 +22,7 @@ import java.util.List;
public class CommandSetLore implements TabExecutor {
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player player)) {
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
return false;
@@ -59,7 +60,7 @@ public class CommandSetLore implements TabExecutor {
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
//TODO: Figure out if there is a better way to display that an argument is required
List options = new ArrayList<>();
options.add("");
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetTitle.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetTitle.java
index 61dab74..d984dc2 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetTitle.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandSetTitle.java
@@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.ItemMeta;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -21,7 +22,7 @@ import java.util.List;
public class CommandSetTitle implements TabExecutor {
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player player)) {
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
return false;
@@ -65,7 +66,7 @@ public class CommandSetTitle implements TabExecutor {
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
List options = new ArrayList<>();
options.add("");
return options;
diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandUnSign.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandUnSign.java
index 510264b..4208d8a 100644
--- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandUnSign.java
+++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandUnSign.java
@@ -10,6 +10,7 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -20,7 +21,7 @@ import java.util.List;
public class CommandUnSign implements TabExecutor {
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player player)) {
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
return false;
@@ -55,7 +56,7 @@ public class CommandUnSign implements TabExecutor {
}
@Override
- public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
return new ArrayList<>();
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 4a98497..ea4a699 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,12 +1,12 @@
name: BooksWithoutBorders
version: '${project.version}'
main: net.knarcraft.bookswithoutborders.BooksWithoutBorders
-api-version: 1.17
+api-version: 1.18
prefix: Books Without Borders
authors: [ EpicKnarvik97, AkiraAkiba ]
description: A continuation of the original Books Without Borders
softdepend: [ Vault ]
-website: ????
+website: https://www.spigotmc.org/resources/books-without-borders-updated.96069/
dev-url: https://git.knarcraft.net/EpicKnarvik97/Books-Without-Borders
commands:
bookswithoutborders:
@@ -85,6 +85,10 @@ commands:
description: Reloads BwB's configuration file
usage: /
permission: bookswithoutborders.admin
+ formatbook:
+ description: Replaces color/formatting codes in a book with formatted text
+ usage: /
+ permission: bookswithoutborders.format
permissions:
bookswithoutborders.*:
description: Grants all permissions
@@ -112,12 +116,15 @@ permissions:
bookswithoutborders.bypassbookprice: true
bookswithoutborders.groupencrypt: true
bookswithoutborders.setbookprice: true
+ bookswithoutborders.format: true
bookswithoutborders.use:
description: Allows player to use commands and to save/load/delete in their personal directory
children:
bookswithoutborders.save: true
bookswithoutborders.load: true
bookswithoutborders.delete: true
+ bookswithoutborders.format:
+ description: Allows a player to format a book
bookswithoutborders.save:
description: Allows player to save books to their personal directory
bookswithoutborders.load:
diff --git a/src/test/java/net/knarcraft/bookswithoutborders/encryption/AESTest.java b/src/test/java/net/knarcraft/bookswithoutborders/encryption/AESTest.java
index d44b73d..963d31e 100644
--- a/src/test/java/net/knarcraft/bookswithoutborders/encryption/AESTest.java
+++ b/src/test/java/net/knarcraft/bookswithoutborders/encryption/AESTest.java
@@ -1,9 +1,9 @@
package net.knarcraft.bookswithoutborders.encryption;
+import junit.framework.Assert;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static junit.framework.Assert.assertEquals;
public class AESTest {
@@ -15,7 +15,7 @@ public class AESTest {
AES aes = new AES(AES.generateIV(), AES.generateIV());
String encrypted = aes.encryptDecryptText(plainText, password, true);
- assertFalse(encrypted.equals(plainText));
+ Assert.assertNotSame(encrypted, plainText);
String decrypted = aes.encryptDecryptText(encrypted, password, false);
assertEquals(plainText, decrypted);
}