This commit is contained in:
spacerocket62 2020-10-28 13:47:00 -07:00
parent ed1abb1fc0
commit a2f7394c88
2 changed files with 29 additions and 0 deletions

View File

@ -20,4 +20,5 @@ public class PlayerCache
{
return plexPlayerMap;
}
}

View File

@ -1,8 +1,16 @@
package me.totalfreedom.plex.util;
import java.sql.SQLException;
import java.util.List;
import java.util.stream.Collectors;
import com.google.common.collect.Lists;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.storage.StorageType;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.PluginCommandYamlParser;
import org.bukkit.plugin.Plugin;
public class PlexUtils
{
@ -32,4 +40,24 @@ public class PlexUtils
}
}
public static boolean isPluginCMD(String cmd, String pluginName)
{
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
if (plugin == null)
{
PlexLog.error(pluginName + " can not be found on the server! Make sure it is spelt correctly!");
return false;
}
List<Command> cmds = PluginCommandYamlParser.parse(plugin);
for (Command pluginCmd : cmds)
{
List<String> cmdAliases = pluginCmd.getAliases().size() > 0 ? pluginCmd.getAliases().stream().map(String::toLowerCase).collect(Collectors.toList()) : null;
if (pluginCmd.getName().equalsIgnoreCase(cmd) || (cmdAliases != null && cmdAliases.contains(cmd.toLowerCase())))
{
return true;
}
}
return false;
}
}