public void updateModPackMods() { try { Map<String, Object> modLibrary = (Map<String, Object>) ModLibraryYML.getModLibraryYML().getProperty("mods"); Map<String, Object> currentModList = ModpackBuild.getSpoutcraftBuild().getMods(); // Remove Mods no longer in previous version removeOldMods(currentModList.keySet()); for (Map.Entry<String, Object> modEntry2 : currentModList.entrySet()) { String modName = modEntry2.getKey(); if (!modLibrary.containsKey(modName)) { throw new IOException(String.format("Mod '%s' is missing from the mod library", modName)); } Map<String, Object> modProperties = (Map<String, Object>) modLibrary.get(modName); Map<String, Object> modVersions = (Map<String, Object>) modProperties.get("versions"); String version = modEntry2.getValue().toString(); if (!modVersions.containsKey(version)) { throw new IOException( String.format( "Mod '%s' version '%s' is missing from the mod library", modName, version)); } String installType = modProperties.containsKey("installtype") ? (String) modProperties.get("installtype") : "zip"; String fullFilename = modName + "-" + version + "." + installType; Boolean isOptional = modProperties.containsKey("optional") ? (Boolean) modProperties.get("optional") : false; String installedModVersion = InstalledModsYML.getInstalledModVersion(modName); // If installed mods md5 hash is the same as server's version // then go to next mod. if (installedModVersion != null && installedModVersion.equals(version)) { String md5ModPath = String.format("mods/%s/%s", modName, fullFilename); if (MD5Utils.checksumCachePath(fullFilename, md5ModPath)) { continue; } } File modFile = new File(tempDir, fullFilename); // If have the mod file then update if (downloadModPackage(modName, fullFilename, modFile)) { updateMod(modFile, modName, version); } } } catch (IOException e) { e.printStackTrace(); } }
public boolean isModpackUpdateAvailable() throws IOException { Map<String, Object> modLibrary = (Map<String, Object>) ModLibraryYML.getModLibraryYML().getProperty("mods"); Map<String, Object> currentModList = ModpackBuild.getSpoutcraftBuild().getMods(); for (Map.Entry<String, Object> modEntry2 : currentModList.entrySet()) { String modName = modEntry2.getKey(); if (!modLibrary.containsKey(modName)) { throw new IOException("Mod is missing from the mod library"); } Map<String, Object> modProperties = (Map<String, Object>) modLibrary.get(modName); Map<String, Object> modVersions = (Map<String, Object>) modProperties.get("versions"); String version = modEntry2.getValue().toString(); if (!modVersions.containsKey(version)) { throw new IOException("Mod version is missing from the mod library"); } String installType = modProperties.get("installtype").toString(); String fullFilename = modName + "-" + version + "." + installType; String md5Name = "mods\\" + modName + "\\" + fullFilename; if (!MD5Utils.checksumCachePath(fullFilename, md5Name)) { return true; } int a = 1; String installedModVersion = InstalledModsYML.getInstalledModVersion(modName); if (installedModVersion == null || !installedModVersion.equals(version)) { return true; } } return false; }