[FEATURE][EXPERIMENTAL] Исправления JAConfigurator

This commit is contained in:
Gravit 2019-08-26 18:34:33 +07:00
parent d65d858bc9
commit 68bdf17e03
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 8 additions and 5 deletions

View file

@ -17,16 +17,18 @@
import pro.gravit.launcher.AutogenConfig; import pro.gravit.launcher.AutogenConfig;
import pro.gravit.launcher.Launcher; import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherConfig; import pro.gravit.launcher.LauncherConfig;
import pro.gravit.launcher.modules.LauncherModule;
import pro.gravit.launcher.modules.LauncherModulesManager;
import pro.gravit.launcher.modules.Module; import pro.gravit.launcher.modules.Module;
import pro.gravit.launcher.modules.ModulesManager; import pro.gravit.launcher.modules.ModulesManager;
import pro.gravit.launchserver.asm.ClassMetadataReader; import pro.gravit.launchserver.asm.ClassMetadataReader;
import pro.gravit.launchserver.asm.SafeClassWriter; import pro.gravit.launchserver.asm.SafeClassWriter;
public class JAConfigurator { public class JAConfigurator {
private static final String modulesManagerName = Type.getInternalName(ModulesManager.class); private static final String modulesManagerName = "pro/gravit/launcher/client/ClientModulesManager";
private static final String launcherName = Type.getInternalName(Launcher.class); private static final String launcherName = "pro/gravit/launcher/LauncherEngine";
private static final String modulesManagerDesc = Type.getDescriptor(ModulesManager.class); private static final String modulesManagerDesc = "Lpro/gravit/launcher/client/ClientModulesManager;";
private static final String registerModDesc = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(Module.class)); private static final String registerModDesc = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(LauncherModule.class));
private static final String autoGenConfigName = Type.getInternalName(AutogenConfig.class); private static final String autoGenConfigName = Type.getInternalName(AutogenConfig.class);
private static final String stringDesc = Type.getDescriptor(String.class); private static final String stringDesc = Type.getDescriptor(String.class);
private final ClassNode configclass; private final ClassNode configclass;
@ -47,7 +49,7 @@ public void addModuleClass(String fullName) {
initModuleMethod.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, launcherName, "modulesManager", modulesManagerDesc)); initModuleMethod.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, launcherName, "modulesManager", modulesManagerDesc));
initModuleMethod.instructions.add(new TypeInsnNode(Opcodes.NEW, fullName.replace('.', '/'))); initModuleMethod.instructions.add(new TypeInsnNode(Opcodes.NEW, fullName.replace('.', '/')));
initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, fullName.replace('.', '/'), "<init>", "()V")); initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, fullName.replace('.', '/'), "<init>", "()V"));
initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, modulesManagerName, "registerModule", registerModDesc)); initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, modulesManagerName, "loadModule", registerModDesc));
} }
public byte[] getBytecode(ClassMetadataReader reader) { public byte[] getBytecode(ClassMetadataReader reader) {

View file

@ -441,6 +441,7 @@ public static void main(String... args) throws Throwable {
//Launcher.modulesManager = new ClientModuleManager(engine); //Launcher.modulesManager = new ClientModuleManager(engine);
LauncherEngine.modulesManager = new ClientModuleManager(); LauncherEngine.modulesManager = new ClientModuleManager();
LauncherConfig.getAutogenConfig().initModules(); //INIT LauncherConfig.getAutogenConfig().initModules(); //INIT
LauncherEngine.modulesManager.initModules(null);
initGson(LauncherEngine.modulesManager); initGson(LauncherEngine.modulesManager);
//Launcher.modulesManager.preInitModules(); //Launcher.modulesManager.preInitModules();
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase()); LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());