예제 #1
0
 void loadBuiltInMods() {
   for (BuiltInMod builtInMod : builtInMods) {
     if (!modsByName.containsKey(builtInMod.name)
         && (MCPatcher.experimentalMods || !builtInMod.experimental)) {
       addNoReplace(newModInstance(builtInMod.modClass));
     }
   }
 }
예제 #2
0
 private boolean addNoReplace(Mod mod) {
   if (mod == null) {
     return false;
   }
   String name = mod.getName();
   if (modsByName.containsKey(name)) {
     Logger.log(Logger.LOG_MOD, "WARNING: duplicate mod %s ignored", name);
     return false;
   }
   mod.setRefs();
   modsByName.put(name, mod);
   modsByIndex.add(mod);
   mod.setEnabled(mod.defaultEnabled);
   mod.loadOptions();
   return true;
 }
예제 #3
0
 private void enableMod(HashMap<Mod, Boolean> inst, Mod mod, boolean recursive)
     throws ModDependencyException {
   if (mod == null) {
     return;
   }
   // Logger.log(Logger.LOG_MOD, "%senabling %s", (recursive ? " " : ""), mod.getName());
   if (!mod.okToApply()) {
     throw new ModDependencyException(mod.getName() + " cannot be applied");
   }
   if (inst.containsKey(mod)) {
     if (!inst.get(mod)) {
       throw new ModDependencyException(mod.getName() + " is both conflicting and required");
     }
     return;
   } else {
     inst.put(mod, true);
   }
   for (Mod.Dependency dep : mod.dependencies) {
     Mod dmod = modsByName.get(dep.name);
     if (dep.required) {
       if (dmod == null) {
         throw new ModDependencyException("dependent mod " + dep.name + " not available");
       } else {
         enableMod(inst, dmod, true);
       }
     } else {
       disableMod(inst, dmod, true);
     }
   }
   for (Mod dmod : modsByIndex) {
     if (dmod != mod) {
       for (Mod.Dependency dep : dmod.dependencies) {
         if (dep.name.equals(mod.getName()) && !dep.required) {
           disableMod(inst, dmod, true);
         }
       }
     }
   }
 }
예제 #4
0
 private void disableMod(HashMap<Mod, Boolean> inst, Mod mod, boolean recursive)
     throws ModDependencyException {
   if (mod == null) {
     return;
   }
   // Logger.log(Logger.LOG_MOD, "%sdisabling %s", (recursive ? " " : ""), mod.getName());
   if (inst.containsKey(mod)) {
     if (inst.get(mod)) {
       throw new ModDependencyException(mod.getName() + " is both conflicting and required");
     }
     return;
   } else {
     inst.put(mod, false);
   }
   for (Mod dmod : modsByIndex) {
     if (dmod != mod) {
       for (Mod.Dependency dep : dmod.dependencies) {
         if (dep.name.equals(mod.getName()) && dep.required) {
           disableMod(inst, dmod, true);
         }
       }
     }
   }
 }