package reborncore.mixin.implementations.asmInjector;

import javassist.ByteArrayClassPath;
import javassist.LoaderClassPath;
import org.apache.logging.log4j.LogManager;
import reborncore.mixin.MixinManager;
import reborncore.mixin.implementations.prebaker.MixinPrebaker;
import reborncore.mixin.transformer.MixinTransformer;

/**
 * Used by asm injector to load mixins into a jar at build time
 */
public class ASMInjectorSetupClass {

	public static void main() {
		MixinManager.logger = LogManager.getLogger();
		MixinManager.logger.info("Loading mixin manager");
		MixinManager.logger.info("Using dummy remapper");
		MixinManager.mixinRemaper = new MixinPrebaker.DummyRemapper();
		MixinManager.load();
	}

	public static void setClassLoader(ClassLoader classLoader) {
		MixinManager.logger.info("Setting class loader");
		MixinTransformer.cp.appendClassPath(new LoaderClassPath(classLoader));
	}

	public static void loadClass(String name, byte[] bytes) {
		MixinTransformer.cp.insertClassPath(new ByteArrayClassPath(name, bytes));
		MixinTransformer.preLoadedClasses.add(name);
	}

}

@@ -457,24 +457,27 @@
  main() %7B%0A%09%09
+if(
 MixinManager
@@ -489,23 +489,25 @@
 er =
- LogManager.get
+= null)%7B%0A%09%09%09setup
 Logg
@@ -508,24 +508,28 @@
 upLogger();%0A
+%09%09%7D%0A
 %09%09MixinManag
@@ -709,24 +709,112 @@
 load();%0A%09%7D%0A%0A
+%09private static void setupLogger()%7B%0A%09%09MixinManager.logger = LogManager.getLogger();%0A%09%7D%0A%0A
 %09public stat
@@ -859,24 +859,81 @@
 ssLoader) %7B%0A
+%09%09if(MixinManager.logger == null)%7B%0A%09%09%09setupLogger();%0A%09%09%7D%0A
 %09%09MixinManag
@@ -1045,24 +1045,24 @@
 ader));%0A%09%7D%0A%0A
-
 %09public stat
@@ -1108,16 +1108,73 @@
 ytes) %7B%0A
+%09%09if(MixinManager.logger == null)%7B%0A%09%09%09setupLogger();%0A%09%09%7D%0A
 %09%09MixinT

Fix ASM injector crash