Created
May 29, 2016 03:47
-
-
Save Prospector/b8b1215c9223c846a5568a73670bd510 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package crystek.modules; | |
| import crystek.Crystek; | |
| import crystek.modules.materials.MaterialsModule; | |
| import net.minecraftforge.fml.common.Loader; | |
| import net.minecraftforge.fml.common.event.FMLInitializationEvent; | |
| import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; | |
| import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| /** | |
| * @author Prospector on 28/05/16 | |
| */ | |
| public class ModuleRegistry | |
| { | |
| public static MaterialsModule materialsModule = new MaterialsModule(); | |
| public static List<Module> modules = new ArrayList<Module>(); | |
| public static List<String> moduleIds = new ArrayList<String>(); | |
| public static void addModules() | |
| { | |
| modules.add(materialsModule); | |
| for(Module i : modules) | |
| moduleIds.add(i.getModuleID()); | |
| } | |
| public static void preInit(FMLPreInitializationEvent event) | |
| { | |
| addModules(); | |
| for (Module i : modules) | |
| { | |
| if (hasRequirements(i)) | |
| { | |
| Crystek.logHelper.info("Module " + i.getModuleID() + " is being PreInitialized"); | |
| i.preInit(event); | |
| } | |
| } | |
| } | |
| public static void init(FMLInitializationEvent event) | |
| { | |
| for (Module i : modules) | |
| { | |
| if (hasRequirements(i)) | |
| { | |
| Crystek.logHelper.info("Module " + i.getModuleID() + " is being Initialized"); | |
| i.init(event); | |
| } | |
| } | |
| } | |
| public static void postInit(FMLPostInitializationEvent event) | |
| { | |
| for (Module i : modules) | |
| { | |
| if (hasRequirements(i)) | |
| { | |
| Crystek.logHelper.info("Module " + i.getModuleID() + " is being PostInitialized"); | |
| i.postInit(event); | |
| } | |
| } | |
| } | |
| public static boolean hasRequirements(Module module) | |
| { | |
| String[] reqMods = module.getModsRequired(); | |
| String[] reqModules = module.getModsRequired(); | |
| if (reqMods != null) | |
| for (String i : reqMods) | |
| { | |
| if (!Loader.isModLoaded(i)) | |
| { | |
| return false; | |
| } | |
| } | |
| if (reqModules != null) | |
| for (String i : reqModules) | |
| { | |
| if (!moduleIds.contains(i)) | |
| { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment