mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Стандартные команды
This commit is contained in:
parent
02613ceef4
commit
a49e523d5d
6 changed files with 32 additions and 32 deletions
|
@ -12,6 +12,9 @@
|
||||||
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.ClearCommand;
|
||||||
|
import ru.gravit.utils.command.basic.DebugCommand;
|
||||||
|
import ru.gravit.utils.command.basic.GCCommand;
|
||||||
import ru.gravit.utils.command.basic.HelpCommand;
|
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 {
|
||||||
|
@ -25,9 +28,9 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl
|
||||||
basic.registerCommand("stop", new StopCommand(server));
|
basic.registerCommand("stop", new StopCommand(server));
|
||||||
basic.registerCommand("restart", new RestartCommand(server));
|
basic.registerCommand("restart", new RestartCommand(server));
|
||||||
basic.registerCommand("rebind", new RebindCommand(server));
|
basic.registerCommand("rebind", new RebindCommand(server));
|
||||||
basic.registerCommand("debug", new DebugCommand(server));
|
basic.registerCommand("debug", new DebugCommand());
|
||||||
basic.registerCommand("clear", new ClearCommand(server));
|
basic.registerCommand("clear", new ClearCommand(handler));
|
||||||
basic.registerCommand("gc", new GCCommand(server));
|
basic.registerCommand("gc", new GCCommand());
|
||||||
basic.registerCommand("proguardClean", new ProguardCleanCommand(server));
|
basic.registerCommand("proguardClean", new ProguardCleanCommand(server));
|
||||||
basic.registerCommand("proguardDictRegen", new RegenProguardDictCommand(server));
|
basic.registerCommand("proguardDictRegen", new RegenProguardDictCommand(server));
|
||||||
basic.registerCommand("proguardMappingsRemove", new RemoveMappingsProguardCommand(server));
|
basic.registerCommand("proguardMappingsRemove", new RemoveMappingsProguardCommand(server));
|
||||||
|
|
|
@ -12,7 +12,7 @@ public String getArgsDescription() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsageDescription() {
|
public String getUsageDescription() {
|
||||||
return "Unlock other commands";
|
return "Unlock console commands";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,6 +22,7 @@ public void invoke(String... args) throws Exception {
|
||||||
{
|
{
|
||||||
LogHelper.info("Unlock successful");
|
LogHelper.info("Unlock successful");
|
||||||
ConsoleManager.unlock();
|
ConsoleManager.unlock();
|
||||||
|
ConsoleManager.handler.unregisterCommand("unlock");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package ru.gravit.launcher.managers;
|
package ru.gravit.launcher.managers;
|
||||||
|
|
||||||
|
import ru.gravit.utils.command.basic.ClearCommand;
|
||||||
|
import ru.gravit.utils.command.basic.DebugCommand;
|
||||||
|
import ru.gravit.utils.command.basic.GCCommand;
|
||||||
import ru.gravit.launcher.console.UnlockCommand;
|
import ru.gravit.launcher.console.UnlockCommand;
|
||||||
import ru.gravit.utils.command.CommandHandler;
|
import ru.gravit.utils.command.CommandHandler;
|
||||||
import ru.gravit.utils.command.JLineCommandHandler;
|
import ru.gravit.utils.command.JLineCommandHandler;
|
||||||
|
@ -34,6 +37,8 @@ public static void initConsole() throws IOException
|
||||||
public static void registerCommands()
|
public static void registerCommands()
|
||||||
{
|
{
|
||||||
handler.registerCommand("help", new HelpCommand(handler));
|
handler.registerCommand("help", new HelpCommand(handler));
|
||||||
|
handler.registerCommand("gc", new GCCommand());
|
||||||
|
handler.registerCommand("clear", new ClearCommand(handler));
|
||||||
handler.registerCommand("unlock", new UnlockCommand());
|
handler.registerCommand("unlock", new UnlockCommand());
|
||||||
}
|
}
|
||||||
public static boolean checkUnlockKey(String key)
|
public static boolean checkUnlockKey(String key)
|
||||||
|
@ -42,6 +47,6 @@ public static boolean checkUnlockKey(String key)
|
||||||
}
|
}
|
||||||
public static void unlock()
|
public static void unlock()
|
||||||
{
|
{
|
||||||
|
handler.registerCommand("debug", new DebugCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package ru.gravit.launchserver.command.basic;
|
package ru.gravit.utils.command.basic;
|
||||||
|
|
||||||
import ru.gravit.launchserver.LaunchServer;
|
import ru.gravit.utils.command.Command;
|
||||||
import ru.gravit.launchserver.command.Command;
|
import ru.gravit.utils.command.CommandHandler;
|
||||||
import ru.gravit.utils.helper.LogHelper;
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public final class ClearCommand extends Command {
|
public final class ClearCommand extends Command {
|
||||||
public ClearCommand(LaunchServer server) {
|
private CommandHandler handler;
|
||||||
super(server);
|
public ClearCommand(CommandHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +22,7 @@ public String getUsageDescription() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) throws Exception {
|
||||||
server.commandHandler.clear();
|
handler.clear();
|
||||||
LogHelper.subInfo("Terminal cleared");
|
LogHelper.subInfo("Terminal cleared");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,26 +1,21 @@
|
||||||
package ru.gravit.launchserver.command.basic;
|
package ru.gravit.utils.command.basic;
|
||||||
|
|
||||||
import ru.gravit.launchserver.LaunchServer;
|
import ru.gravit.utils.command.Command;
|
||||||
import ru.gravit.launchserver.command.Command;
|
|
||||||
import ru.gravit.utils.helper.LogHelper;
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public final class DebugCommand extends Command {
|
public class DebugCommand extends Command {
|
||||||
public DebugCommand(LaunchServer server) {
|
|
||||||
super(server);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getArgsDescription() {
|
public String getArgsDescription() {
|
||||||
return "[true/false] (true/false)";
|
return "[true/false] [true/false]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsageDescription() {
|
public String getUsageDescription() {
|
||||||
return "Enable or disable debug and stacktrace logging at runtime";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) {
|
public void invoke(String... args) throws Exception {
|
||||||
boolean newValue, newTraceValue;
|
boolean newValue, newTraceValue;
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
newValue = Boolean.parseBoolean(args[0]);
|
newValue = Boolean.parseBoolean(args[0]);
|
|
@ -1,16 +1,11 @@
|
||||||
package ru.gravit.launchserver.command.basic;
|
package ru.gravit.utils.command.basic;
|
||||||
|
|
||||||
import ru.gravit.launcher.managers.GarbageManager;
|
import ru.gravit.launcher.managers.GarbageManager;
|
||||||
import ru.gravit.launchserver.LaunchServer;
|
import ru.gravit.utils.command.Command;
|
||||||
import ru.gravit.launchserver.command.Command;
|
|
||||||
import ru.gravit.utils.helper.JVMHelper;
|
import ru.gravit.utils.helper.JVMHelper;
|
||||||
import ru.gravit.utils.helper.LogHelper;
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public final class GCCommand extends Command {
|
public class GCCommand extends Command {
|
||||||
public GCCommand(LaunchServer server) {
|
|
||||||
super(server);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getArgsDescription() {
|
public String getArgsDescription() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -18,11 +13,11 @@ public String getArgsDescription() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsageDescription() {
|
public String getUsageDescription() {
|
||||||
return "Perform Garbage Collection and print memory usage";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) {
|
public void invoke(String... args) throws Exception {
|
||||||
LogHelper.subInfo("Performing full GC");
|
LogHelper.subInfo("Performing full GC");
|
||||||
JVMHelper.fullGC();
|
JVMHelper.fullGC();
|
||||||
GarbageManager.gc();
|
GarbageManager.gc();
|
Loading…
Reference in a new issue