0

Added the ability to unload using the fallback.*

* Unfortunately it still won't remove the commands from the TabComplete
* Also, changed the error msg from an unregistered command to help
lessen the confusion on the previous issue.
This commit is contained in:
Minenash
2019-01-13 00:32:55 -05:00
parent 8f2200619e
commit ff281241b5
3 changed files with 51 additions and 8 deletions

View File

@@ -35,17 +35,23 @@ public class Executable extends org.bukkit.command.Command {
private ArrayList<ExecutableDefinition> commands;
private ArrayList<HelpPageCommand[]> help;
private String name;
private String methodContainerName;
private JavaPlugin plugin;
public Executable(String name, ArrayList<HelpPageCommand[]> help) {
public Executable(String name, ArrayList<HelpPageCommand[]> help, String methodContainerName) {
super(name);
this.help = help;
this.name = name;
this.commands = new ArrayList<ExecutableDefinition>();
this.methodContainerName = methodContainerName;
}
public String getMethodContainerName() {
return methodContainerName;
}
public void register(ArrayList<Method> methods, JavaPlugin plugin, Object methodContainer, ArrayList<String> aliases) {
String moduleName = methodContainer.getClass().getSimpleName();
methodContainerName = methodContainer.getClass().getSimpleName().toLowerCase();
for (HelpPageCommand[] page : help) {
for (HelpPageCommand cmd : page) {
if (cmd != null) {
@@ -95,13 +101,13 @@ public class Executable extends org.bukkit.command.Command {
@SuppressWarnings("unchecked")
Map<String, Command> knownCommands = (Map<String, Command>) knownCommandsField.get(map);
knownCommands.remove(name);
map.register(moduleName, this);
map.register(methodContainerName, this);
for (String alias : aliases) {
Executable cmd = new Executable(alias, this.help);
Executable cmd = new Executable(alias, this.help, methodContainerName);
cmd.commands = this.commands;
cmd.plugin = this.plugin;
knownCommands.remove(alias);
map.register(moduleName, cmd);
map.register(methodContainerName, cmd);
}
} catch (Exception e) {
plugin.getLogger().log(Level.SEVERE, "Failed to register command '" + name + "'!");