[FEATURE] Стандартные команды

This commit is contained in:
Gravit 2019-04-24 16:18:34 +07:00
parent 02613ceef4
commit a49e523d5d
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
6 changed files with 32 additions and 32 deletions

View file

@ -12,6 +12,9 @@
import ru.gravit.launchserver.command.modules.ModulesCommand;
import ru.gravit.launchserver.command.service.*;
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;
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("restart", new RestartCommand(server));
basic.registerCommand("rebind", new RebindCommand(server));
basic.registerCommand("debug", new DebugCommand(server));
basic.registerCommand("clear", new ClearCommand(server));
basic.registerCommand("gc", new GCCommand(server));
basic.registerCommand("debug", new DebugCommand());
basic.registerCommand("clear", new ClearCommand(handler));
basic.registerCommand("gc", new GCCommand());
basic.registerCommand("proguardClean", new ProguardCleanCommand(server));
basic.registerCommand("proguardDictRegen", new RegenProguardDictCommand(server));
basic.registerCommand("proguardMappingsRemove", new RemoveMappingsProguardCommand(server));

View file

@ -12,7 +12,7 @@ public String getArgsDescription() {
@Override
public String getUsageDescription() {
return "Unlock other commands";
return "Unlock console commands";
}
@Override
@ -22,6 +22,7 @@ public void invoke(String... args) throws Exception {
{
LogHelper.info("Unlock successful");
ConsoleManager.unlock();
ConsoleManager.handler.unregisterCommand("unlock");
}
else
{

View file

@ -1,5 +1,8 @@
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.utils.command.CommandHandler;
import ru.gravit.utils.command.JLineCommandHandler;
@ -34,6 +37,8 @@ public static void initConsole() throws IOException
public static void registerCommands()
{
handler.registerCommand("help", new HelpCommand(handler));
handler.registerCommand("gc", new GCCommand());
handler.registerCommand("clear", new ClearCommand(handler));
handler.registerCommand("unlock", new UnlockCommand());
}
public static boolean checkUnlockKey(String key)
@ -42,6 +47,6 @@ public static boolean checkUnlockKey(String key)
}
public static void unlock()
{
handler.registerCommand("debug", new DebugCommand());
}
}

View file

@ -1,12 +1,13 @@
package ru.gravit.launchserver.command.basic;
package ru.gravit.utils.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.command.Command;
import ru.gravit.utils.command.CommandHandler;
import ru.gravit.utils.helper.LogHelper;
public final class ClearCommand extends Command {
public ClearCommand(LaunchServer server) {
super(server);
private CommandHandler handler;
public ClearCommand(CommandHandler handler) {
this.handler = handler;
}
@Override
@ -21,7 +22,7 @@ public String getUsageDescription() {
@Override
public void invoke(String... args) throws Exception {
server.commandHandler.clear();
handler.clear();
LogHelper.subInfo("Terminal cleared");
}
}

View file

@ -1,26 +1,21 @@
package ru.gravit.launchserver.command.basic;
package ru.gravit.utils.command.basic;
import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.command.Command;
import ru.gravit.utils.helper.LogHelper;
public final class DebugCommand extends Command {
public DebugCommand(LaunchServer server) {
super(server);
}
public class DebugCommand extends Command {
@Override
public String getArgsDescription() {
return "[true/false] (true/false)";
return "[true/false] [true/false]";
}
@Override
public String getUsageDescription() {
return "Enable or disable debug and stacktrace logging at runtime";
return null;
}
@Override
public void invoke(String... args) {
public void invoke(String... args) throws Exception {
boolean newValue, newTraceValue;
if (args.length >= 1) {
newValue = Boolean.parseBoolean(args[0]);

View file

@ -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.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.command.Command;
import ru.gravit.utils.helper.JVMHelper;
import ru.gravit.utils.helper.LogHelper;
public final class GCCommand extends Command {
public GCCommand(LaunchServer server) {
super(server);
}
public class GCCommand extends Command {
@Override
public String getArgsDescription() {
return null;
@ -18,11 +13,11 @@ public String getArgsDescription() {
@Override
public String getUsageDescription() {
return "Perform Garbage Collection and print memory usage";
return null;
}
@Override
public void invoke(String... args) {
public void invoke(String... args) throws Exception {
LogHelper.subInfo("Performing full GC");
JVMHelper.fullGC();
GarbageManager.gc();