Esempio n. 1
0
 private void updateModElement(Mod mod, Element element) {
   Config config = MCPatcherUtils.config;
   if (mod instanceof ExternalMod) {
     ExternalMod extmod = (ExternalMod) mod;
     config.setText(element, Config.TAG_TYPE, Config.VAL_EXTERNAL_ZIP);
     config.setText(element, Config.TAG_PATH, extmod.zipFile.getName());
     Element files = config.getElement(element, Config.TAG_FILES);
     while (files.hasChildNodes()) {
       files.removeChild(files.getFirstChild());
     }
     for (Map.Entry<String, String> entry : extmod.fileMap.entrySet()) {
       Element fileElem = config.xml.createElement(Config.TAG_FILE);
       Element pathElem = config.xml.createElement(Config.TAG_FROM);
       pathElem.appendChild(config.xml.createTextNode(entry.getValue()));
       fileElem.appendChild(pathElem);
       pathElem = config.xml.createElement(Config.TAG_TO);
       pathElem.appendChild(config.xml.createTextNode(entry.getKey()));
       fileElem.appendChild(pathElem);
       files.appendChild(fileElem);
     }
   } else if (mod.customJar == null) {
     config.setText(element, Config.TAG_TYPE, Config.VAL_BUILTIN);
   } else {
     config.setText(element, Config.TAG_TYPE, Config.VAL_EXTERNAL_JAR);
     config.setText(element, Config.TAG_PATH, mod.customJar.getPath());
     config.setText(element, Config.TAG_CLASS, mod.getClass().getCanonicalName());
   }
 }
Esempio n. 2
0
 HashMap<String, String> getReverseMap() {
   HashMap<String, String> map = new HashMap<String, String>();
   for (Mod mod : modsByIndex) {
     for (Map.Entry<String, String> entry : mod.getClassMap().getReverseClassMap().entrySet()) {
       map.put(entry.getKey(), entry.getValue());
     }
   }
   return map;
 }
Esempio n. 3
0
 void selectMod(Mod mod, boolean enable) {
   HashMap<Mod, Boolean> changes = new HashMap<Mod, Boolean>();
   try {
     if (enable) {
       enableMod(changes, mod, false);
     } else {
       disableMod(changes, mod, false);
     }
   } catch (ModDependencyException e) {
     Logger.log(e);
   }
   for (Map.Entry<Mod, Boolean> entry : changes.entrySet()) {
     mod = entry.getKey();
     mod.setEnabled(entry.getValue());
   }
   refreshInternalMods();
 }
Esempio n. 4
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());
   }
 }