Removes some code unnecessary for tab executors

This commit is contained in:
Kristian Knarvik 2021-09-08 15:31:32 +02:00
parent be1717182d
commit c44f64e42b

View File

@ -30,8 +30,6 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.command.TabExecutor;
import org.bukkit.configuration.Configuration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFactory;
@ -263,27 +261,25 @@ public class BooksWithoutBorders extends JavaPlugin {
* Registers all commands used by this plugin
*/
private void registerCommands() {
TabExecutor giveTabExecutor = new CommandGive();
registerCommand("giveBook", giveTabExecutor, giveTabExecutor);
TabExecutor givePublicTabExecutor = new CommandGivePublic();
registerCommand("givePublicBook", givePublicTabExecutor, givePublicTabExecutor);
registerCommand("decryptBook", new CommandDecrypt(), null);
registerCommand("groupEncryptBook", new CommandGroupEncrypt(), null);
registerCommand("deleteBook", new CommandDelete(), null);
registerCommand("deletePublicBook", new CommandDeletePublic(), null);
registerCommand("copyBook", new CommandCopy(), null);
registerCommand("unSignBook", new CommandUnSign(), null);
registerCommand("encryptBook", new CommandEncrypt(), null);
registerCommand("setBookPrice", new CommandSetBookPrice(), null);
registerCommand("setLore", new CommandSetLore(), null);
registerCommand("savePublicBook", new CommandSavePublic(), null);
registerCommand("saveBook", new CommandSave(), null);
registerCommand("setBookAuthor", new CommandSetAuthor(), null);
registerCommand("setTitle", new CommandSetTitle(), null);
registerCommand("loadBook", new CommandLoad(), null);
registerCommand("loadPublicBook", new CommandLoadPublic(), null);
registerCommand("booksWithoutBorders", new CommandBooksWithoutBorders(), null);
registerCommand("reload", new CommandReload(), null);
registerCommand("giveBook", new CommandGive());
registerCommand("givePublicBook", new CommandGivePublic());
registerCommand("decryptBook", new CommandDecrypt());
registerCommand("groupEncryptBook", new CommandGroupEncrypt());
registerCommand("deleteBook", new CommandDelete());
registerCommand("deletePublicBook", new CommandDeletePublic());
registerCommand("copyBook", new CommandCopy());
registerCommand("unSignBook", new CommandUnSign());
registerCommand("encryptBook", new CommandEncrypt());
registerCommand("setBookPrice", new CommandSetBookPrice());
registerCommand("setLore", new CommandSetLore());
registerCommand("savePublicBook", new CommandSavePublic());
registerCommand("saveBook", new CommandSave());
registerCommand("setBookAuthor", new CommandSetAuthor());
registerCommand("setTitle", new CommandSetTitle());
registerCommand("loadBook", new CommandLoad());
registerCommand("loadPublicBook", new CommandLoadPublic());
registerCommand("booksWithoutBorders", new CommandBooksWithoutBorders());
registerCommand("reload", new CommandReload());
}
/**
@ -292,13 +288,10 @@ public class BooksWithoutBorders extends JavaPlugin {
* @param commandName <p>The name of the command to register</p>
* @param executor <p>The executor to register for the command</p>
*/
private void registerCommand(String commandName, CommandExecutor executor, TabCompleter tabCompleter) {
private void registerCommand(String commandName, CommandExecutor executor) {
PluginCommand pluginCommand = this.getCommand(commandName);
if (pluginCommand != null) {
pluginCommand.setExecutor(executor);
if (tabCompleter != null) {
pluginCommand.setTabCompleter(tabCompleter);
}
} else {
sendErrorMessage(consoleSender, "Failed to register command " + commandName);
}