diff --git a/pom.xml b/pom.xml index c028e01..8d32e96 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.knarcraft BooksWithoutBorders - 1.0 + 1.1 jar @@ -20,7 +20,7 @@ A continuation of the original Books Without Borders - 16 + 17 UTF-8 @@ -31,8 +31,8 @@ maven-compiler-plugin 3.8.1 - ${java.version} - ${java.version} + 17 + 17 @@ -75,7 +75,7 @@ org.spigotmc spigot-api - 1.17.1-R0.1-SNAPSHOT + 1.18.1-R0.1-SNAPSHOT provided @@ -84,5 +84,11 @@ 1.7 provided + + org.jetbrains + annotations + 23.0.0 + compile + diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandBooksWithoutBorders.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandBooksWithoutBorders.java index bf7e494..85be445 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandBooksWithoutBorders.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandBooksWithoutBorders.java @@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -24,7 +25,7 @@ public class CommandBooksWithoutBorders implements TabExecutor { private final BooksWithoutBorders booksWithoutBorders = BooksWithoutBorders.getInstance(); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { sender.sendMessage(getCommandColor() + "[] denote optional parameters"); sender.sendMessage(getCommandColor() + "<> denote required parameters"); sender.sendMessage(getCommandColor() + "In some cases, commands with required parameters can be called with no parameters"); @@ -107,7 +108,7 @@ public class CommandBooksWithoutBorders 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/CommandCopy.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java index 3d1d98b..7aadb5c 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.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.util.ArrayList; import java.util.List; @@ -24,7 +25,7 @@ public class CommandCopy 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 (!(sender instanceof Player player)) { BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!"); return false; @@ -46,8 +47,9 @@ public class CommandCopy implements TabExecutor { int copies = Integer.parseInt(args[0]); if (copies > 0) { if (BooksWithoutBorders.getAuthorOnlyCopy() && !player.hasPermission("bookswithoutborders.bypassAuthorOnlyCopy")) { - if (!isAuthor(player, (BookMeta) Objects.requireNonNull(heldBook.getItemMeta()))) + if (!isAuthor(player, (BookMeta) Objects.requireNonNull(heldBook.getItemMeta()))) { return false; + } } if (booksWithoutBorders.booksHavePrice() && @@ -86,7 +88,7 @@ public class CommandCopy 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) { int argumentCount = args.length; if (argumentCount == 1) { return TabCompletionHelper.getNumbers(1, 20); diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java index d202128..f9260ee 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.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.io.File; import java.util.ArrayList; @@ -23,7 +24,7 @@ import static net.knarcraft.bookswithoutborders.BooksWithoutBordersSettings.getS public class CommandDecrypt 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; @@ -102,7 +103,7 @@ public class CommandDecrypt 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) { int argumentCount = args.length; if (argumentCount == 1) { List info = new ArrayList<>(); diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDelete.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDelete.java index d87cf28..d8fc3fd 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDelete.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDelete.java @@ -7,6 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; @@ -21,7 +22,7 @@ import static net.knarcraft.bookswithoutborders.BooksWithoutBordersSettings.getS public class CommandDelete 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)) { BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!"); return false; @@ -107,14 +108,15 @@ public class CommandDelete 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 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 deletePublic

Whether to delete a public book

* @return

A list of available arguments

*/ diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDeletePublic.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDeletePublic.java index fc2be66..ceb8b6b 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDeletePublic.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDeletePublic.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 CommandDeletePublic extends CommandDelete 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 deleteBook(sender, args, 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/CommandEncrypt.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandEncrypt.java index d8490e2..9ee12f6 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandEncrypt.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandEncrypt.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.util.ArrayList; import java.util.List; @@ -21,7 +22,7 @@ import java.util.List; public class 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, @NotNull String[] args) { if (performPreChecks(sender, args, 1, "You must specify a key to encrypt a book!") == null) { return false; } @@ -96,13 +97,14 @@ public class 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, false); } /** * Gets a list of string for tab completions - * @param args

The arguments given

+ * + * @param args

The arguments given

* @param groupEncrypt

Whether to auto-complete for group encryption

* @return

The strings to auto-complete

*/ diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGive.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGive.java index a89d76f..745af1c 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGive.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandGive.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 CommandGive 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 (!(sender instanceof Player)) { BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!"); return false; @@ -104,14 +105,15 @@ public class CommandGive 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 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); }