Пример #1
0
 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());
     }
   }
 }
Пример #2
0
 ArrayList<Mod> getSelected() {
   ArrayList<Mod> list = new ArrayList<Mod>();
   for (Mod mod : modsByIndex) {
     if (mod.okToApply() && mod.isEnabled()) {
       list.add(mod);
     }
   }
   return list;
 }
Пример #3
0
 private void refreshInternalMods() {
   modsByIndex.remove(baseMod);
   modsByIndex.remove(texturePackMod);
   modsByIndex.add(0, baseMod);
   modsByIndex.add(1, texturePackMod);
   outer:
   while (true) {
     for (int i = 0; i < modsByIndex.size() - 1; i++) {
       Mod mod1 = modsByIndex.get(i);
       Mod mod2 = modsByIndex.get(i + 1);
       if (mod1.internal && !dependsOn(mod2, mod1)) {
         modsByIndex.set(i, mod2);
         modsByIndex.set(i + 1, mod1);
         continue outer;
       }
     }
     break;
   }
   for (Mod mod : modsByIndex) {
     if (mod.internal) {
       mod.setEnabled(false);
     }
   }
   HashMap<Mod, Boolean> changes = new HashMap<Mod, Boolean>();
   for (Mod mod : modsByIndex) {
     try {
       if (mod.internal) {
         // nothing
       } else if (mod.isEnabled()) {
         enableMod(changes, mod, false);
       } else {
         disableMod(changes, mod, false);
       }
     } catch (ModDependencyException e) {
       Logger.log(e);
     }
   }
   for (Map.Entry<Mod, Boolean> entry : changes.entrySet()) {
     Mod mod = entry.getKey();
     mod.setEnabled(entry.getValue());
   }
 }