Add /su commandinfo command
This command will output information about the specified command, like which plugin it belongs to, which usages, aliases, names, description and permissions it has. Permission to use the command is `serverutils.commandinfo`.
This commit is contained in:
parent
4c035fdc59
commit
04f3314e8a
4 changed files with 76 additions and 9 deletions
|
|
@ -107,17 +107,20 @@ public class PluginManager {
|
|||
return enablePlugin(loadResult.getPlugin());
|
||||
}
|
||||
|
||||
public static void unregisterCommands(Plugin plugin) {
|
||||
SimpleCommandMap commandMap = RCraftServer.getCommandMap();
|
||||
Map<String, Command> map;
|
||||
public static Map<String, Command> getKnownCommands() {
|
||||
try {
|
||||
map = RCommandMap.getKnownCommands(commandMap);
|
||||
return RCommandMap.getKnownCommands(RCraftServer.getCommandMap());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
map.values().removeIf(c -> {
|
||||
public static void unregisterCommands(Plugin plugin) {
|
||||
Map<String, Command> knownCommands = getKnownCommands();
|
||||
if (knownCommands == null) return;
|
||||
|
||||
knownCommands.values().removeIf(c -> {
|
||||
if (c instanceof PluginCommand) {
|
||||
PluginCommand pc = (PluginCommand) c;
|
||||
if (pc.getPlugin() == plugin) {
|
||||
|
|
@ -129,4 +132,10 @@ public class PluginManager {
|
|||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public static Command getCommand(String command) {
|
||||
Map<String, Command> knownCommands = getKnownCommands();
|
||||
if (knownCommands == null) return null;
|
||||
return knownCommands.get(command);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue