[FEATURE] API лаунчера, доступное извне без знания о маппингах ProGuard

This commit is contained in:
Gravit 2019-09-18 02:56:13 +07:00
parent 0e278b715b
commit 053ca39dfe
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
5 changed files with 45 additions and 2 deletions

View file

@ -20,9 +20,9 @@
-keepattributes Signature
-adaptresourcefilecontents META-INF/MANIFEST.MF
-keeppackagenames com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**
-keeppackagenames com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.client.api.**
-keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.** {
-keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.client.api.** {
*;
}

View file

@ -0,0 +1,19 @@
package pro.gravit.launcher.api;
import pro.gravit.launcher.ClientPermissions;
import java.util.UUID;
public class AuthService {
public static String username;
public static ClientPermissions permissions = new ClientPermissions();
public static UUID uuid;
public static boolean isAdmin()
{
return permissions.canAdmin;
}
public static boolean isServer()
{
return permissions.canServer;
}
}

View file

@ -0,0 +1,10 @@
package pro.gravit.launcher.api;
import java.lang.instrument.Instrumentation;
import java.net.URL;
public class ClientService {
public static Instrumentation instrumentation;
public static ClassLoader classLoader;
public static URL[] baseURLs;
}

View file

@ -32,6 +32,8 @@
import pro.gravit.launcher.LauncherAgent;
import pro.gravit.launcher.LauncherConfig;
import pro.gravit.launcher.LauncherEngine;
import pro.gravit.launcher.api.AuthService;
import pro.gravit.launcher.api.ClientService;
import pro.gravit.launcher.client.events.ClientLauncherInitPhase;
import pro.gravit.launcher.guard.LauncherGuardManager;
import pro.gravit.launcher.gui.JSRuntimeProvider;
@ -518,6 +520,11 @@ public static void main(String... args) throws Throwable {
LogHelper.error(e);
}
};
AuthService.username = params.pp.username;
AuthService.uuid = params.pp.uuid;
ClientService.instrumentation = LauncherAgent.inst;
ClientService.classLoader = classLoader;
ClientService.baseURLs = classpathurls;
LogHelper.debug("Starting JVM and client WatchService");
FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher();
FileNameMatcher clientMatcher = profile.getClientUpdateMatcher();

View file

@ -7,6 +7,7 @@
import java.util.concurrent.atomic.AtomicReference;
import pro.gravit.launcher.LauncherAPI;
import pro.gravit.launcher.api.AuthService;
import pro.gravit.launcher.events.request.AuthRequestEvent;
import pro.gravit.launcher.guard.LauncherGuardManager;
import pro.gravit.launcher.hasher.FileNameMatcher;
@ -100,6 +101,12 @@ public static void setAuthParams(AuthRequestEvent event) {
Request.setSession(event.session);
}
LauncherGuardManager.guard.setProtectToken(event.protectToken);
AuthService.permissions = event.permissions;
if(event.playerProfile != null)
{
AuthService.username = event.playerProfile.username;
AuthService.uuid = event.playerProfile.uuid;
}
}
@FunctionalInterface