mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +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);
|
verifyArgs(args, 1);
|
||||||
if (ConsoleManager.checkUnlockKey(args[0])) {
|
if (ConsoleManager.checkUnlockKey(args[0])) {
|
||||||
LogHelper.info("Unlock successful");
|
LogHelper.info("Unlock successful");
|
||||||
ConsoleManager.unlock();
|
if(!ConsoleManager.unlock())
|
||||||
ConsoleManager.handler.unregisterCommand("unlock");
|
{
|
||||||
|
LogHelper.error("Console unlock canceled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
LogHelper.info("Write unlock key");
|
LogHelper.info("Write unlock key");
|
||||||
SettingsManager.settings.consoleUnlockKey = args[0];
|
SettingsManager.settings.consoleUnlockKey = args[0];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package pro.gravit.launcher.managers;
|
package pro.gravit.launcher.managers;
|
||||||
|
|
||||||
import pro.gravit.launcher.Launcher;
|
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.launcher.console.UnlockCommand;
|
||||||
import pro.gravit.utils.command.CommandHandler;
|
import pro.gravit.utils.command.CommandHandler;
|
||||||
import pro.gravit.utils.command.JLineCommandHandler;
|
import pro.gravit.utils.command.JLineCommandHandler;
|
||||||
|
@ -48,8 +50,14 @@ public static boolean checkUnlockKey(String key) {
|
||||||
return key.equals(Launcher.getConfig().oemUnlockKey);
|
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.registerCommand("debug", new DebugCommand());
|
||||||
|
handler.unregisterCommand("unlock");
|
||||||
isConsoleUnlock = true;
|
isConsoleUnlock = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue