mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] ClientUnlockConsoleEvent
This commit is contained in:
parent
036b593356
commit
495dba899d
3 changed files with 26 additions and 3 deletions
|
@ -0,0 +1,12 @@
|
|||
package pro.gravit.launcher.client.events;
|
||||
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
|
||||
public class ClientUnlockConsoleEvent extends LauncherModule.Event {
|
||||
public final CommandHandler handler;
|
||||
|
||||
public ClientUnlockConsoleEvent(CommandHandler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
}
|
|
@ -21,8 +21,11 @@ public void invoke(String... args) throws Exception {
|
|||
verifyArgs(args, 1);
|
||||
if (ConsoleManager.checkUnlockKey(args[0])) {
|
||||
LogHelper.info("Unlock successful");
|
||||
ConsoleManager.unlock();
|
||||
ConsoleManager.handler.unregisterCommand("unlock");
|
||||
if(!ConsoleManager.unlock())
|
||||
{
|
||||
LogHelper.error("Console unlock canceled");
|
||||
return;
|
||||
}
|
||||
LogHelper.info("Write unlock key");
|
||||
SettingsManager.settings.consoleUnlockKey = args[0];
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package pro.gravit.launcher.managers;
|
||||
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.LauncherEngine;
|
||||
import pro.gravit.launcher.client.events.ClientUnlockConsoleEvent;
|
||||
import pro.gravit.launcher.console.UnlockCommand;
|
||||
import pro.gravit.utils.command.CommandHandler;
|
||||
import pro.gravit.utils.command.JLineCommandHandler;
|
||||
|
@ -48,8 +50,14 @@ public static boolean checkUnlockKey(String key) {
|
|||
return key.equals(Launcher.getConfig().oemUnlockKey);
|
||||
}
|
||||
|
||||
public static void unlock() {
|
||||
public static boolean unlock() {
|
||||
if(isConsoleUnlock) return true;
|
||||
ClientUnlockConsoleEvent event = new ClientUnlockConsoleEvent(handler);
|
||||
LauncherEngine.modulesManager.invokeEvent(event);
|
||||
if(event.isCancel()) return false;
|
||||
handler.registerCommand("debug", new DebugCommand());
|
||||
handler.unregisterCommand("unlock");
|
||||
isConsoleUnlock = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue