/** * Register a new command and all of its aliases to this command manager. * * @param command the command to register * @return the command manager this was called on, allows for chaining */ public CommandManager registerCommand(Command command) { if (command == null) return this; this.commands.put(command.getName().toLowerCase(), command); if (command.getAliases().length != 0) { for (String aliases : command.getAliases()) { commands.put(aliases.toLowerCase(), command); } } return this; }
for (CommandArgument commandArgument : this.commands.get(a[0].toLowerCase()).getCommandArguments()) this.commands.get(a[0].toLowerCase()).onExecuteCommand(sender, new String[0]); } else this.commands.get(a[0].toLowerCase()).onExecuteCommand(sender, c); for (CommandArgument commandArgument : this.commands.get(a[0].toLowerCase()).getCommandArguments())
@Override public void onExecuteCommand(CommandSender sender, String[] args) { List<String> messages = new ArrayList<>(CloudNet.getInstance().getCommandManager().getCommands().size() + 9); for (String command : CloudNet.getInstance().getCommandManager().getCommands()) messages.add(command + " | " + CloudNet.getInstance().getCommandManager().getCommand(command).getDescription()); messages.add(NetworkUtils.SPACE_STRING); messages.add("Server groups:"); messages.add(Arrays.toString(CloudNet.getInstance().getServerGroups().keySet().toArray(new String[0]))); messages.add("Proxy groups:"); messages.add(Arrays.toString(CloudNet.getInstance().getProxyGroups().keySet().toArray(new String[0]))); messages.add(NetworkUtils.SPACE_STRING); messages.add("The Cloud uses " + (ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1048576L) + NetworkUtils.SLASH_STRING + (ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax() / 1048576L) + "MB"); messages.add("CPU on this instance " + new DecimalFormat("##.##").format(NetworkUtils.internalCpuUsage()) + "/100 %"); messages.add(NetworkUtils.SPACE_STRING); sender.sendMessage(messages.toArray(new String[0])); } }