fix wildcard and clean up command executor

This commit is contained in:
Super_
2020-07-01 12:45:09 -04:00
parent 9d7e0cdefc
commit 5421de0c2f
3 changed files with 35 additions and 12 deletions

View File

@ -1,8 +1,11 @@
package me.totalfreedom.totalfreedommod.command;
import java.nio.channels.FileLock;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -30,16 +33,30 @@ public class Command_wildcard extends FreedomCommand
return false;
}
FreedomCommand command = plugin.cl.getByName(args[0]);
if (command == null)
Command runCmd = server.getPluginCommand(args[0]);
FreedomCommand fCmd = plugin.cl.getByName(args[0]);
boolean alias = plugin.cl.isAlias(args[0]);
if (runCmd == null && fCmd == null && !alias)
{
msg("Unknown command: " + args[0], ChatColor.RED);
return true;
}
List<String> aliases = new ArrayList<>();
if (runCmd != null)
{
aliases = runCmd.getAliases();
}
if (fCmd != null)
{
aliases = Arrays.asList(fCmd.getAliases().split(","));
}
for (String blockedCommand : BLOCKED_COMMANDS)
{
if (blockedCommand.equals(command.getName()) || command.getAliases().contains(blockedCommand))
if (blockedCommand.equals(args[0].toLowerCase()) || aliases.contains(blockedCommand))
{
msg("Did you really think that was going to work?", ChatColor.RED);
return true;