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