mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
Перенос initModules
This commit is contained in:
parent
75cc2156a0
commit
8f76bfdf03
4 changed files with 37 additions and 15 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarInputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
@ -29,4 +30,16 @@ public void pushJarFile(JarInputStream input) throws IOException {
|
|||
e = input.getNextEntry();
|
||||
}
|
||||
}
|
||||
public void pushJarFile(JarInputStream input, Set<String> blacklist) throws IOException {
|
||||
ZipEntry e = input.getNextEntry();
|
||||
while (e != null) {
|
||||
if(blacklist.contains(e.getName())){
|
||||
e = input.getNextEntry();
|
||||
continue;
|
||||
}
|
||||
output.putNextEntry(e);
|
||||
IOHelper.transfer(input,output);
|
||||
e = input.getNextEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,36 +2,35 @@
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javassist.CannotCompileException;
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtConstructor;
|
||||
import javassist.NotFoundException;
|
||||
import javassist.*;
|
||||
|
||||
public class JAConfigurator implements AutoCloseable {
|
||||
ClassPool pool = ClassPool.getDefault();
|
||||
CtClass ctClass;
|
||||
CtConstructor ctConstructor;
|
||||
CtMethod initModuleMethod;
|
||||
String classname;
|
||||
StringBuilder body;
|
||||
StringBuilder moduleBody;
|
||||
int autoincrement;
|
||||
public JAConfigurator(Class<?> configclass) throws NotFoundException {
|
||||
classname = configclass.getName();
|
||||
ctClass = pool.get(classname);
|
||||
ctConstructor = ctClass.getDeclaredConstructor(null);
|
||||
body = new StringBuilder("{");
|
||||
initModuleMethod = ctClass.getDeclaredMethod("initModules");
|
||||
body = new StringBuilder("{ isInitModules = false; ");
|
||||
autoincrement = 0;
|
||||
}
|
||||
public void addModuleClass(String fullName)
|
||||
{
|
||||
body.append("ru.gravit.launcher.modules.Module mod");
|
||||
body.append(autoincrement);
|
||||
body.append(" = new ");
|
||||
body.append(fullName);
|
||||
body.append("();");
|
||||
body.append("ru.gravit.launcher.Launcher.modulesManager.registerModule( mod");
|
||||
body.append(autoincrement);
|
||||
body.append(" , true );");
|
||||
moduleBody.append("ru.gravit.launcher.modules.Module mod");
|
||||
moduleBody.append(autoincrement);
|
||||
moduleBody.append(" = new ");
|
||||
moduleBody.append(fullName);
|
||||
moduleBody.append("();");
|
||||
moduleBody.append("ru.gravit.launcher.Launcher.modulesManager.registerModule( mod");
|
||||
moduleBody.append(autoincrement);
|
||||
moduleBody.append(" , true );");
|
||||
autoincrement++;
|
||||
}
|
||||
@Override
|
||||
|
@ -41,6 +40,7 @@ public void close() {
|
|||
public byte[] getBytecode() throws IOException, CannotCompileException {
|
||||
body.append("}");
|
||||
ctConstructor.setBody(body.toString());
|
||||
initModuleMethod.insertAfter(moduleBody.toString());
|
||||
return ctClass.toBytecode();
|
||||
}
|
||||
public String getZipEntryPath()
|
||||
|
@ -60,4 +60,8 @@ public void setPort(int port)
|
|||
body.append(port);
|
||||
body.append(";");
|
||||
}
|
||||
public ClassPool getPool()
|
||||
{
|
||||
return pool;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ public static Process launch(
|
|||
@LauncherAPI
|
||||
public static void main(String... args) throws Throwable {
|
||||
Launcher.modulesManager = new ClientModuleManager(null);
|
||||
LauncherConfig.getAutogenConfig(); //INIT
|
||||
LauncherConfig.getAutogenConfig().initModules(); //INIT
|
||||
Launcher.modulesManager.preInitModules();
|
||||
if (JVMHelper.OS_TYPE == OS.MUSTDIE) {
|
||||
AvanguardStarter.loadVared();
|
||||
|
|
|
@ -4,7 +4,12 @@ public class AutogenConfig {
|
|||
public String projectname;
|
||||
public String address;
|
||||
public int port;
|
||||
private boolean isInitModules;
|
||||
AutogenConfig() {
|
||||
|
||||
}
|
||||
public void initModules()
|
||||
{
|
||||
if(isInitModules) return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue