Merge pull request #256 from Focusvity/pr/command-fix

Plugin-specific registration fix
This commit is contained in:
Telesphoreo 2020-08-04 14:29:38 -05:00 committed by GitHub
commit 299b31a75b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,10 +82,19 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
public void register()
{
FCommand cmd = new FCommand(this.name);
if (this.aliases != null) cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ",")));
if (this.description != null) cmd.setDescription(this.description);
if (this.usage != null) cmd.setUsage(this.usage);
getCommandMap().register("", cmd);
if (this.aliases != null)
{
cmd.setAliases(Arrays.asList(StringUtils.split(this.aliases, ",")));
}
if (this.description != null)
{
cmd.setDescription(this.description);
}
if (this.usage != null)
{
cmd.setUsage(this.usage);
}
getCommandMap().register("totalfreedommod", cmd);
cmd.setExecutor(this);
}
@ -97,7 +106,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
{
final Field f = Bukkit.getServer().getPluginManager().getClass().getDeclaredField("commandMap");
f.setAccessible(true);
commandMap = (CommandMap) f.get(Bukkit.getServer().getPluginManager());
commandMap = (CommandMap)f.get(Bukkit.getServer().getPluginManager());
}
catch (Exception e)
{
@ -110,10 +119,12 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
private final class FCommand extends Command
{
private FreedomCommand cmd = null;
private FCommand(String command)
{
super(command);
}
public void setExecutor(FreedomCommand cmd)
{
this.cmd = cmd;