Added generic mod checker

This commit is contained in:
Francesco Macagno 2015-08-17 23:04:22 -07:00
parent f5821029bf
commit bb921c6907

View file

@ -0,0 +1,31 @@
package cr0s.warpdrive.conf;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import cpw.mods.fml.common.Loader;
public class ModRequirementChecker {
public static String getMissingMods(Element e) throws InvalidXmlException {
String missingMods = "";
NodeList mods = e.getElementsByTagName("mod");
for (int j = 0; j < mods.getLength(); j++) {
Element mod = (Element) mods.item(j);
if (!mod.hasAttribute("name")) {
throw new InvalidXmlException("A mod requirement is missing the name attribute!");
}
String name = mod.getAttribute("name");
if (!Loader.isModLoaded(name)) {
missingMods = missingMods + name + ", ";
}
}
return missingMods;
}
}