mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Полностью распределены команды по категориям, команда help доступна из libLauncher
This commit is contained in:
parent
1f716f0307
commit
7869618d51
2 changed files with 31 additions and 25 deletions
|
@ -12,13 +12,14 @@
|
||||||
import ru.gravit.launchserver.command.modules.ModulesCommand;
|
import ru.gravit.launchserver.command.modules.ModulesCommand;
|
||||||
import ru.gravit.launchserver.command.service.*;
|
import ru.gravit.launchserver.command.service.*;
|
||||||
import ru.gravit.utils.command.BaseCommandCategory;
|
import ru.gravit.utils.command.BaseCommandCategory;
|
||||||
|
import ru.gravit.utils.command.basic.HelpCommand;
|
||||||
|
|
||||||
public abstract class CommandHandler extends ru.gravit.utils.command.CommandHandler {
|
public abstract class CommandHandler extends ru.gravit.utils.command.CommandHandler {
|
||||||
public static void registerCommands(ru.gravit.utils.command.CommandHandler handler) {
|
public static void registerCommands(ru.gravit.utils.command.CommandHandler handler) {
|
||||||
LaunchServer server = LaunchServer.server;
|
LaunchServer server = LaunchServer.server;
|
||||||
BaseCommandCategory basic = new BaseCommandCategory();
|
BaseCommandCategory basic = new BaseCommandCategory();
|
||||||
// Register basic commands
|
// Register basic commands
|
||||||
basic.registerCommand("help", new HelpCommand(server));
|
basic.registerCommand("help", new HelpCommand(server.commandHandler));
|
||||||
basic.registerCommand("version", new VersionCommand(server));
|
basic.registerCommand("version", new VersionCommand(server));
|
||||||
basic.registerCommand("build", new BuildCommand(server));
|
basic.registerCommand("build", new BuildCommand(server));
|
||||||
basic.registerCommand("stop", new StopCommand(server));
|
basic.registerCommand("stop", new StopCommand(server));
|
||||||
|
@ -61,22 +62,28 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl
|
||||||
handler.registerCategory(authCategory);
|
handler.registerCategory(authCategory);
|
||||||
|
|
||||||
//Register dump commands
|
//Register dump commands
|
||||||
handler.registerCommand("dumpSessions", new DumpSessionsCommand(server));
|
BaseCommandCategory dump = new BaseCommandCategory();
|
||||||
handler.registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server));
|
dump.registerCommand("dumpSessions", new DumpSessionsCommand(server));
|
||||||
|
dump.registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server));
|
||||||
|
Category dumpCategory = new Category(dump,"dump", "Dump runtime data");
|
||||||
|
handler.registerCategory(dumpCategory);
|
||||||
|
|
||||||
//Register service commands
|
//Register service commands
|
||||||
handler.registerCommand("reload", new ReloadCommand(server));
|
BaseCommandCategory service = new BaseCommandCategory();
|
||||||
handler.registerCommand("reloadAll", new ReloadAllCommand(server));
|
service.registerCommand("reload", new ReloadCommand(server));
|
||||||
handler.registerCommand("reloadList", new ReloadListCommand(server));
|
service.registerCommand("reloadAll", new ReloadAllCommand(server));
|
||||||
handler.registerCommand("config", new ConfigCommand(server));
|
service.registerCommand("reloadList", new ReloadListCommand(server));
|
||||||
handler.registerCommand("configHelp", new ConfigHelpCommand(server));
|
service.registerCommand("config", new ConfigCommand(server));
|
||||||
handler.registerCommand("configList", new ConfigListCommand(server));
|
service.registerCommand("configHelp", new ConfigHelpCommand(server));
|
||||||
handler.registerCommand("serverStatus", new ServerStatusCommand(server));
|
service.registerCommand("configList", new ConfigListCommand(server));
|
||||||
handler.registerCommand("checkInstall", new CheckInstallCommand(server));
|
service.registerCommand("serverStatus", new ServerStatusCommand(server));
|
||||||
handler.registerCommand("multi", new MultiCommand(server));
|
service.registerCommand("checkInstall", new CheckInstallCommand(server));
|
||||||
handler.registerCommand("getModulus", new GetModulusCommand(server));
|
service.registerCommand("multi", new MultiCommand(server));
|
||||||
handler.registerCommand("component", new ComponentCommand(server));
|
service.registerCommand("getModulus", new GetModulusCommand(server));
|
||||||
handler.registerCommand("givePermission", new GivePermissionsCommand(server));
|
service.registerCommand("component", new ComponentCommand(server));
|
||||||
handler.registerCommand("getPermissions", new GetPermissionsCommand(server));
|
service.registerCommand("givePermission", new GivePermissionsCommand(server));
|
||||||
|
service.registerCommand("getPermissions", new GetPermissionsCommand(server));
|
||||||
|
Category serviceCategory = new Category(service,"service", "Managing LaunchServer Components");
|
||||||
|
handler.registerCategory(serviceCategory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package ru.gravit.launchserver.command.basic;
|
package ru.gravit.utils.command.basic;
|
||||||
|
|
||||||
import org.fusesource.jansi.Ansi;
|
import org.fusesource.jansi.Ansi;
|
||||||
import ru.gravit.launchserver.LaunchServer;
|
|
||||||
import ru.gravit.utils.command.Command;
|
import ru.gravit.utils.command.Command;
|
||||||
import ru.gravit.utils.command.CommandCategory;
|
|
||||||
import ru.gravit.utils.command.CommandException;
|
import ru.gravit.utils.command.CommandException;
|
||||||
import ru.gravit.utils.command.CommandHandler;
|
import ru.gravit.utils.command.CommandHandler;
|
||||||
import ru.gravit.utils.helper.LogHelper;
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
@ -11,7 +9,8 @@
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public final class HelpCommand extends ru.gravit.launchserver.command.Command {
|
public final class HelpCommand extends Command {
|
||||||
|
private CommandHandler handler;
|
||||||
private static void printCommand(String name, Command command) {
|
private static void printCommand(String name, Command command) {
|
||||||
String args = command.getArgsDescription();
|
String args = command.getArgsDescription();
|
||||||
//LogHelper.subInfo("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription());
|
//LogHelper.subInfo("%s %s - %s", name, args == null ? "[nothing]" : args, command.getUsageDescription());
|
||||||
|
@ -36,8 +35,8 @@ private static void printCategory(String name, String description)
|
||||||
else LogHelper.info("Category: %s", name);
|
else LogHelper.info("Category: %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HelpCommand(LaunchServer server) {
|
public HelpCommand(CommandHandler handler) {
|
||||||
super(server);
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,18 +61,18 @@ public void invoke(String... args) throws CommandException {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printCommand(String name) throws CommandException {
|
private void printCommand(String name) throws CommandException {
|
||||||
printCommand(name, server.commandHandler.lookup(name));
|
printCommand(name, handler.lookup(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printCommands() {
|
private void printCommands() {
|
||||||
for(CommandHandler.Category category : server.commandHandler.getCategories())
|
for(CommandHandler.Category category : handler.getCategories())
|
||||||
{
|
{
|
||||||
printCategory(category.name, category.description);
|
printCategory(category.name, category.description);
|
||||||
for (Entry<String, Command> entry : category.category.commandsMap().entrySet())
|
for (Entry<String, Command> entry : category.category.commandsMap().entrySet())
|
||||||
printCommand(entry.getKey(), entry.getValue());
|
printCommand(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
printCategory("Base", null);
|
printCategory("Base", null);
|
||||||
for (Entry<String, Command> entry : server.commandHandler.getBaseCategory().commandsMap().entrySet())
|
for (Entry<String, Command> entry : handler.getBaseCategory().commandsMap().entrySet())
|
||||||
printCommand(entry.getKey(), entry.getValue());
|
printCommand(entry.getKey(), entry.getValue());
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue