private static boolean register(Class clazz) { if (clazz.isAnnotationPresent(Compat.class)) { Compat annotation = (Compat) clazz.getAnnotation(Compat.class); if (Loader.isModLoaded(annotation.value())) { modules.add(clazz); return true; } else { MOLog.log( Level.INFO, "The mod %s was not loaded, skipping compatibility module.", annotation.value()); return false; } } MOLog.log(Level.ERROR, "There was a problem register a compatibility module!"); return false; }
public static void init(FMLInitializationEvent event) { MOLog.log( Level.INFO, "Attempting to run initialization methods for all registered compatibility modules."); for (Class clazz : modules) { for (Method m : clazz.getMethods()) { if (m.isAnnotationPresent(Compat.Init.class) && Modifier.isStatic(m.getModifiers())) { try { m.invoke(null, event); } catch (ReflectiveOperationException e) { Compat annotation = (Compat) clazz.getAnnotation(Compat.class); MOLog.log( Level.ERROR, e, "There was an error trying to invoke the initialization method of the compatibility module for %1$s", annotation.value()); e.printStackTrace(); } } } } }