void updateProperties() { Config config = MCPatcherUtils.config; Element mods = config.getMods(); if (mods == null) { return; } HashMap<String, Element> oldElements = new HashMap<String, Element>(); while (mods.hasChildNodes()) { Node node = mods.getFirstChild(); if (node instanceof Element) { Element element = (Element) node; String name = config.getText(element, Config.TAG_NAME); if (name != null) { oldElements.put(name, element); } } mods.removeChild(node); } for (Mod mod : modsByIndex) { if (mod.internal) { continue; } Element element = oldElements.get(mod.getName()); if (element == null) { defaultModElement(mod); } else { config.setText( element, Config.TAG_ENABLED, Boolean.toString(mod.isEnabled() && mod.okToApply())); updateModElement(mod, element); mods.appendChild(element); oldElements.remove(mod.getName()); } } }
void remove(Mod mod) { String name = mod.getName(); for (int i = 0; i < modsByIndex.size(); i++) { if (modsByIndex.get(i) == mod) { modsByIndex.remove(i); modsByName.remove(name); } } mod.close(); }