mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-22 16:05:03 +00:00
Simplify command executor assignment a little more
This commit is contained in:
parent
f45d332727
commit
45de495699
1 changed files with 11 additions and 15 deletions
|
@ -352,17 +352,11 @@ public class OpenInv extends JavaPlugin implements IOpenInv {
|
||||||
pm.registerEvents(new InventoryListener(this), this);
|
pm.registerEvents(new InventoryListener(this), this);
|
||||||
|
|
||||||
// Register commands to their executors
|
// Register commands to their executors
|
||||||
OpenInvCommand openInv = new OpenInvCommand(this);
|
this.setCommandExecutor(new OpenInvCommand(this), "openinv", "openender");
|
||||||
this.setCommandExecutor("openinv", openInv);
|
this.setCommandExecutor(new SearchContainerCommand(this), "searchcontainer");
|
||||||
this.setCommandExecutor("openender", openInv);
|
this.setCommandExecutor(new SearchInvCommand(this), "searchinv", "searchender");
|
||||||
this.setCommandExecutor("searchcontainer", new SearchContainerCommand(this));
|
this.setCommandExecutor(new SearchEnchantCommand(this), "searchenchant");
|
||||||
SearchInvCommand searchInv = new SearchInvCommand(this);
|
this.setCommandExecutor(new ContainerSettingCommand(this), "silentcontainer", "anycontainer");
|
||||||
this.setCommandExecutor("searchinv", searchInv);
|
|
||||||
this.setCommandExecutor("searchender", searchInv);
|
|
||||||
this.setCommandExecutor("searchenchant", new SearchEnchantCommand(this));
|
|
||||||
ContainerSettingCommand settingCommand = new ContainerSettingCommand(this);
|
|
||||||
this.setCommandExecutor("silentcontainer", settingCommand);
|
|
||||||
this.setCommandExecutor("anycontainer", settingCommand);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.sendVersionError(this.getLogger()::warning);
|
this.sendVersionError(this.getLogger()::warning);
|
||||||
|
@ -375,10 +369,12 @@ public class OpenInv extends JavaPlugin implements IOpenInv {
|
||||||
messageMethod.accept("Please obtain an appropriate version here: " + accessor.getReleasesLink());
|
messageMethod.accept("Please obtain an appropriate version here: " + accessor.getReleasesLink());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCommandExecutor(String commandName, CommandExecutor executor) {
|
private void setCommandExecutor(CommandExecutor executor, String... commands) {
|
||||||
PluginCommand command = this.getCommand(commandName);
|
for (String commandName : commands) {
|
||||||
if (command != null) {
|
PluginCommand command = this.getCommand(commandName);
|
||||||
command.setExecutor(executor);
|
if (command != null) {
|
||||||
|
command.setExecutor(executor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue