コード例 #1
0
 private boolean doInstallMod(final ModuleIdentifier modID) {
   checkWorkerContext();
   if (repos.isEmpty()) {
     log.warn("No repositories configured!");
     return false;
   }
   if (locateModule(null, modID) != null) {
     log.error("Module is already installed");
     return false;
   }
   ModuleZipInfo info = getModule(modID);
   if (info != null) {
     return unzipModule(modID, info, true);
   }
   return false;
 }
コード例 #2
0
 private boolean doPullInDependencies(File modRoot, ModuleIdentifier modID) {
   File modDir = new File(modRoot, modID.toString());
   if (!modDir.exists()) {
     log.error("Cannot find module to uninstall");
   }
   JsonObject conf = loadModuleConfig(modID, modDir);
   if (conf == null) {
     log.error("Module " + modID + " does not contain a mod.json");
   }
   ModuleFields fields = new ModuleFields(conf);
   List<String> mods = new ArrayList<>();
   String includes = fields.getIncludes();
   if (includes != null) {
     mods.addAll(Arrays.asList(parseIncludeString(includes)));
   }
   String deploys = fields.getDeploys();
   if (deploys != null) {
     mods.addAll(Arrays.asList(parseIncludeString(deploys)));
   }
   if (!mods.isEmpty()) {
     File internalModsDir = new File(modDir, "mods");
     if (!internalModsDir.exists()) {
       internalModsDir.mkdir();
     }
     for (String modName : mods) {
       File internalModDir = new File(internalModsDir, modName);
       if (!internalModDir.exists()) {
         ModuleIdentifier theModID = new ModuleIdentifier(modName);
         ModuleZipInfo zipInfo = getModule(theModID);
         if (zipInfo.filename != null) {
           internalModDir.mkdir();
           if (!unzipModuleData(internalModDir, zipInfo, true)) {
             return false;
           } else {
             log.info("Module " + modName + " successfully installed in mods dir of " + modName);
             // Now recurse so we bring in all of the deps
             doPullInDependencies(internalModsDir, theModID);
           }
         }
       }
     }
   }
   return true;
 }