Beispiel #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());
   }
 }
Beispiel #2
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());
     }
   }
 }
Beispiel #3
0
 private Element defaultModElement(Mod mod) {
   Config config = MCPatcherUtils.config;
   Element mods = config.getMods();
   if (mods == null) {
     return null;
   }
   Element element = config.getMod(mod.getName());
   config.setText(element, Config.TAG_ENABLED, Boolean.toString(mod.defaultEnabled));
   updateModElement(mod, element);
   return element;
 }