mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Событие закрытия клиента, сервис обработки exit/setSecurityManager
This commit is contained in:
parent
a125fd8e8f
commit
3bfed5c3c7
6 changed files with 68 additions and 1 deletions
|
@ -1,7 +1,9 @@
|
||||||
package pro.gravit.launcher;
|
package pro.gravit.launcher;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.api.SystemService;
|
||||||
import pro.gravit.launcher.client.*;
|
import pro.gravit.launcher.client.*;
|
||||||
import pro.gravit.launcher.client.events.ClientEngineInitPhase;
|
import pro.gravit.launcher.client.events.ClientEngineInitPhase;
|
||||||
|
import pro.gravit.launcher.client.events.ClientExitPhase;
|
||||||
import pro.gravit.launcher.client.events.ClientPreGuiPhase;
|
import pro.gravit.launcher.client.events.ClientPreGuiPhase;
|
||||||
import pro.gravit.launcher.guard.LauncherGuardManager;
|
import pro.gravit.launcher.guard.LauncherGuardManager;
|
||||||
import pro.gravit.launcher.gui.NoRuntimeProvider;
|
import pro.gravit.launcher.gui.NoRuntimeProvider;
|
||||||
|
@ -10,11 +12,13 @@
|
||||||
import pro.gravit.launcher.managers.ClientGsonManager;
|
import pro.gravit.launcher.managers.ClientGsonManager;
|
||||||
import pro.gravit.launcher.managers.ClientHookManager;
|
import pro.gravit.launcher.managers.ClientHookManager;
|
||||||
import pro.gravit.launcher.managers.ConsoleManager;
|
import pro.gravit.launcher.managers.ConsoleManager;
|
||||||
|
import pro.gravit.launcher.modules.events.ClosePhase;
|
||||||
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
||||||
import pro.gravit.launcher.request.Request;
|
import pro.gravit.launcher.request.Request;
|
||||||
import pro.gravit.launcher.request.RequestException;
|
import pro.gravit.launcher.request.RequestException;
|
||||||
import pro.gravit.launcher.request.auth.RestoreSessionRequest;
|
import pro.gravit.launcher.request.auth.RestoreSessionRequest;
|
||||||
import pro.gravit.launcher.request.websockets.StdWebSocketService;
|
import pro.gravit.launcher.request.websockets.StdWebSocketService;
|
||||||
|
import pro.gravit.launcher.utils.NativeJVMHalt;
|
||||||
import pro.gravit.utils.helper.*;
|
import pro.gravit.utils.helper.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -53,6 +57,18 @@ public static void checkClass(Class<?> clazz) throws SecurityException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void exitLauncher(int code)
|
||||||
|
{
|
||||||
|
modulesManager.invokeEvent(new ClientExitPhase(code));
|
||||||
|
try {
|
||||||
|
System.exit(code);
|
||||||
|
} catch (Exception e) //Forge Security Manager?
|
||||||
|
{
|
||||||
|
NativeJVMHalt.haltA(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws Throwable {
|
public static void main(String... args) throws Throwable {
|
||||||
JVMHelper.checkStackTrace(LauncherEngine.class);
|
JVMHelper.checkStackTrace(LauncherEngine.class);
|
||||||
JVMHelper.verifySystemProperties(Launcher.class, true);
|
JVMHelper.verifySystemProperties(Launcher.class, true);
|
||||||
|
@ -84,7 +100,7 @@ public static void main(String... args) throws Throwable {
|
||||||
LogHelper.debug("Launcher started in %dms", endTime - startTime);
|
LogHelper.debug("Launcher started in %dms", endTime - startTime);
|
||||||
//Request.service.close();
|
//Request.service.close();
|
||||||
//FunctionalBridge.close();
|
//FunctionalBridge.close();
|
||||||
System.exit(0);
|
SystemService.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initGson(ClientModuleManager modulesManager) {
|
public static void initGson(ClientModuleManager modulesManager) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package pro.gravit.launcher.api;
|
package pro.gravit.launcher.api;
|
||||||
|
|
||||||
import pro.gravit.launcher.ClientPermissions;
|
import pro.gravit.launcher.ClientPermissions;
|
||||||
|
import pro.gravit.launcher.profiles.ClientProfile;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -8,6 +9,7 @@ public class AuthService {
|
||||||
public static String username;
|
public static String username;
|
||||||
public static ClientPermissions permissions = new ClientPermissions();
|
public static ClientPermissions permissions = new ClientPermissions();
|
||||||
public static UUID uuid;
|
public static UUID uuid;
|
||||||
|
public static ClientProfile profile;
|
||||||
|
|
||||||
public static boolean isAdmin() {
|
public static boolean isAdmin() {
|
||||||
return permissions.canAdmin;
|
return permissions.canAdmin;
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package pro.gravit.launcher.api;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.LauncherEngine;
|
||||||
|
import pro.gravit.launcher.profiles.ClientProfile;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
|
public class SystemService {
|
||||||
|
private SystemService() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
public static void exit(int code)
|
||||||
|
{
|
||||||
|
LauncherEngine.exitLauncher(code);
|
||||||
|
}
|
||||||
|
public static void setSecurityManager(SecurityManager s)
|
||||||
|
{
|
||||||
|
LogHelper.debug("Try set security manager %s", s == null ? "null" : s.getClass().getName());
|
||||||
|
if(AuthService.profile == null || AuthService.profile.securityManagerConfig == ClientProfile.SecurityManagerConfig.NONE) return;
|
||||||
|
if(AuthService.profile.securityManagerConfig == ClientProfile.SecurityManagerConfig.CLIENT)
|
||||||
|
{
|
||||||
|
System.setSecurityManager(s);
|
||||||
|
}
|
||||||
|
//TODO NEXT
|
||||||
|
}
|
||||||
|
}
|
|
@ -463,6 +463,7 @@ public static void main(String... args) throws Throwable {
|
||||||
HashedDir assetHDir = p.assetHDir, clientHDir = p.clientHDir;
|
HashedDir assetHDir = p.assetHDir, clientHDir = p.clientHDir;
|
||||||
ClientLaunchContext context = new ClientLaunchContext(params, profile, assetHDir, clientHDir);
|
ClientLaunchContext context = new ClientLaunchContext(params, profile, assetHDir, clientHDir);
|
||||||
Launcher.profile = profile;
|
Launcher.profile = profile;
|
||||||
|
AuthService.profile = profile;
|
||||||
playerProfile = params.pp;
|
playerProfile = params.pp;
|
||||||
Request.setSession(params.session);
|
Request.setSession(params.session);
|
||||||
checkJVMBitsAndVersion();
|
checkJVMBitsAndVersion();
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package pro.gravit.launcher.client.events;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.modules.events.ClosePhase;
|
||||||
|
|
||||||
|
public class ClientExitPhase extends ClosePhase {
|
||||||
|
public final int code;
|
||||||
|
|
||||||
|
public ClientExitPhase(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
}
|
|
@ -69,6 +69,14 @@ public String toString() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final boolean profileCaseSensitive = Boolean.getBoolean("launcher.clientProfile.caseSensitive");
|
public static final boolean profileCaseSensitive = Boolean.getBoolean("launcher.clientProfile.caseSensitive");
|
||||||
|
public enum SecurityManagerConfig
|
||||||
|
{
|
||||||
|
NONE, CLIENT, LAUNCHER, MIXED
|
||||||
|
}
|
||||||
|
public enum ClassLoaderConfig
|
||||||
|
{
|
||||||
|
AGENT, LAUNCHER
|
||||||
|
}
|
||||||
|
|
||||||
private static final FileNameMatcher ASSET_MATCHER = new FileNameMatcher(
|
private static final FileNameMatcher ASSET_MATCHER = new FileNameMatcher(
|
||||||
new String[0], new String[]{"indexes", "objects"}, new String[0]);
|
new String[0], new String[]{"indexes", "objects"}, new String[0]);
|
||||||
|
@ -122,6 +130,10 @@ public String toString() {
|
||||||
private final List<String> clientArgs = new ArrayList<>();
|
private final List<String> clientArgs = new ArrayList<>();
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
private final List<String> whitelist = new ArrayList<>();
|
private final List<String> whitelist = new ArrayList<>();
|
||||||
|
@LauncherNetworkAPI
|
||||||
|
public SecurityManagerConfig securityManagerConfig = SecurityManagerConfig.CLIENT;
|
||||||
|
@LauncherNetworkAPI
|
||||||
|
public ClassLoaderConfig classLoaderConfig = ClassLoaderConfig.LAUNCHER;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ClientProfile o) {
|
public int compareTo(ClientProfile o) {
|
||||||
|
|
Loading…
Reference in a new issue