blob: c7c5b070e22b0946dd016b87603ae2f0efe096b9 [file] [log] [blame] [raw]
package li.cil.occ.mods;
import cpw.mods.fml.common.Loader;
import li.cil.occ.OpenComponents;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
public final class Registry {
private static final Set<IMod> handlers = new HashSet<IMod>();
private Registry() {
}
public static void add(final IMod mod) {
final boolean alwaysEnabled = mod.getModId() == null || mod.getModId().isEmpty() || "Minecraft".equals(mod.getModId());
if ((alwaysEnabled || Loader.isModLoaded(mod.getModId())) && handlers.add(mod)) {
OpenComponents.Log.info(String.format("Initializing drivers for '%s'.", mod.getModId()));
try {
mod.initialize();
} catch (Throwable e) {
OpenComponents.Log.log(Level.WARNING, String.format("Error initializing handler for '%s'", mod.getModId()), e);
}
}
}
}