예제 #1
0
 public static void findAndLoad() {
   if (loaded_mods) {
     System.err.println("Already loaded mod system, trying to load again?");
     return;
   }
   System.err.println("EL Mod System starting...");
   if (!injectModsFolder()) {
     System.err.println(
         "[WARNING] Mods folder does not exist or is a file, "
             + "add it if you want mods to be loaded from there.");
   }
   ArrayList<IMod> injected = ModInjector.findAndInject();
   System.err.println("Loaded mods from classpath.");
   System.err.println("Letting game mess with mods list...");
   KMain inst = KMain.getInst();
   inst.loadMods(injected);
   System.err.println("Complete.");
   loaded.addAll(injected);
   System.err.println("Initializing mods...");
   for (IMod m : loaded) {
     try {
       m.init(inst);
     } catch (Exception e) {
       System.err.println("Error registering mod " + m.getClass() + ":");
       e.printStackTrace();
       injected.remove(m);
     }
   }
   System.err.println("Complete.");
   loaded = injected;
   loaded.trimToSize();
   loaded_mods = true;
   System.err.println("EL Mod System loaded.");
   ModuleSystem.loadModulesFromMods();
 }
예제 #2
0
 public static void registerRenders(
     HashMap<Class<? extends ELEntity>, Render<? extends ELEntity>> classToRender) {
   if (!loaded_mods) {
     throw new IllegalStateException("Registering renderers before loading mods!");
   }
   for (IMod m : loaded) {
     HashMap<Class<? extends ELEntity>, Render<? extends ELEntity>> tmp =
         new HashMap<Class<? extends ELEntity>, Render<? extends ELEntity>>();
     m.registerRenders(tmp);
     classToRender.putAll(tmp);
   }
 }