| 1 | package net.oni2.aeinstaller.backend.packages; | 
 
 
 
 
 | 2 |  | 
 
 
 
 
 | 3 | import java.io.BufferedReader; | 
 
 
 
 
 | 4 | import java.io.File; | 
 
 
 
 
 | 5 | import java.io.FileInputStream; | 
 
 
 
 
 | 6 | import java.io.FileNotFoundException; | 
 
 
 
 
 | 7 | import java.io.FilenameFilter; | 
 
 
 
 
 | 8 | import java.io.IOException; | 
 
 
 
 
 | 9 | import java.io.InputStreamReader; | 
 
 
 
 
 | 10 | import java.net.URI; | 
 
 
 
 
 | 11 | import java.net.URISyntaxException; | 
 
 
 
 
 | 12 | import java.util.HashSet; | 
 
 
 
 
 | 13 |  | 
 
 
 
 
 | 14 | import net.oni2.aeinstaller.backend.CaseInsensitiveFile; | 
 
 
 
 
 | 15 | import net.oni2.aeinstaller.backend.Paths; | 
 
 
 
 
 | 16 | import net.oni2.aeinstaller.backend.oni.management.tools.ToolInstallationList; | 
 
 
 
 
 | 17 | import net.oni2.moddepot.DepotConfig; | 
 
 
 
 
 | 18 | import net.oni2.moddepot.ECompatiblePlatform; | 
 
 
 
 
 | 19 | import net.oni2.moddepot.model.NodeMod; | 
 
 
 
 
 | 20 | import net.oni2.platformtools.PlatformInformation; | 
 
 
 
 
 | 21 | import net.oni2.platformtools.PlatformInformation.Platform; | 
 
 
 
 
 | 22 | import net.oni2.platformtools.applicationinvoker.EExeType; | 
 
 
 
 
 | 23 |  | 
 
 
 
 
 | 24 | import org.apache.commons.io.FileUtils; | 
 
 
 
 
 | 25 |  | 
 
 
 
 
 | 26 | /** | 
 
 
 
 
 | 27 | * @author Christian Illy | 
 
 
 
 
 | 28 | */ | 
 
 
 
 
 | 29 | public class Package implements Comparable<Package> { | 
 
 
 
 
 | 30 | private String name = ""; | 
 
 
 
 
 | 31 | private int packageNumber = 0; | 
 
 
 
 
 | 32 |  | 
 
 
 
 
 | 33 | private HashSet<Type> types = new HashSet<Type>(); | 
 
 
 
 
 | 34 | private boolean tool = false; | 
 
 
 
 
 | 35 | private ECompatiblePlatform platform = null; | 
 
 
 
 
 | 36 | private String version = ""; | 
 
 
 
 
 | 37 | private String submitter = ""; | 
 
 
 
 
 | 38 | private String creator = ""; | 
 
 
 
 
 | 39 | private transient EBSLInstallType bslInstallType = EBSLInstallType.NORMAL; | 
 
 
 
 
 | 40 | private String description = ""; | 
 
 
 
 
 | 41 | private transient double aeVersion = 0; | 
 
 
 
 
 | 42 | private int zipSize = 0; | 
 
 
 
 
 | 43 |  | 
 
 
 
 
 | 44 | private URI nodeUrl = null; | 
 
 
 
 
 | 45 | private String fileUrl = null; | 
 
 
 
 
 | 46 |  | 
 
 
 
 
 | 47 | private long createdMillis = -1; | 
 
 
 
 
 | 48 | private long updatedMillis = -1; | 
 
 
 
 
 | 49 |  | 
 
 
 
 
 | 50 | private transient File exeFile = null; | 
 
 
 
 
 | 51 | private transient EExeType exeType = EExeType.OSBINARY; | 
 
 
 
 
 | 52 | private transient File iconFile = null; | 
 
 
 
 
 | 53 | private transient String workingDir = "Base"; | 
 
 
 
 
 | 54 |  | 
 
 
 
 
 | 55 | private transient HashSet<Integer> incompatibilities = new HashSet<Integer>(); | 
 
 
 
 
 | 56 | private transient HashSet<Integer> dependencies = new HashSet<Integer>(); | 
 
 
 
 
 | 57 | private transient HashSet<Integer> unlockLevel = new HashSet<Integer>(); | 
 
 
 
 
 | 58 |  | 
 
 
 
 
 | 59 | private transient long localTimestamp = 0; | 
 
 
 
 
 | 60 |  | 
 
 
 
 
 | 61 | /** | 
 
 
 
 
 | 62 | * Create a new Package entry from a given Mod-Node | 
 
 
 
 
 | 63 | * | 
 
 
 
 
 | 64 | * @param nm | 
 
 
 
 
 | 65 | *            Mod-Node | 
 
 
 
 
 | 66 | */ | 
 
 
 
 
 | 67 | public Package(NodeMod nm) { | 
 
 
 
 
 | 68 | name = nm.getTitle(); | 
 
 
 
 
 | 69 | packageNumber = nm.getPackageNumber(); | 
 
 
 
 
 | 70 | platform = nm.getPlatform(); | 
 
 
 
 
 | 71 | tool = nm.isTool(); | 
 
 
 
 
 | 72 | for (String nType : nm.getTypes()) { | 
 
 
 
 
 | 73 | Type t = PackageManager.getInstance().getTypeByName(nType); | 
 
 
 
 
 | 74 | types.add(t); | 
 
 
 
 
 | 75 | if (!tool && !isCorePackage() && isValidOnPlatform()) | 
 
 
 
 
 | 76 | t.addEntry(this); | 
 
 
 
 
 | 77 | } | 
 
 
 
 
 | 78 |  | 
 
 
 
 
 | 79 | createdMillis = nm.getCreated(); | 
 
 
 
 
 | 80 | updatedMillis = nm.getUploads().firstElement().getTimestamp(); | 
 
 
 
 
 | 81 |  | 
 
 
 
 
 | 82 | try { | 
 
 
 
 
 | 83 | nodeUrl = new URI(nm.getPath()); | 
 
 
 
 
 | 84 | } catch (URISyntaxException e) { | 
 
 
 
 
 | 85 | e.printStackTrace(); | 
 
 
 
 
 | 86 | } | 
 
 
 
 
 | 87 |  | 
 
 
 
 
 | 88 | fileUrl = nm.getUploads().firstElement().getUri_full(); | 
 
 
 
 
 | 89 | zipSize = nm.getUploads().firstElement().getFilesize(); | 
 
 
 
 
 | 90 |  | 
 
 
 
 
 | 91 | version = nm.getVersion(); | 
 
 
 
 
 | 92 | submitter = nm.getName(); | 
 
 
 
 
 | 93 | creator = nm.getCreator(); | 
 
 
 
 
 | 94 | if (nm.getBody() != null) { | 
 
 
 
 
 | 95 | description = nm.getBody().getSafe_value(); | 
 
 
 
 
 | 96 | if (!description.toLowerCase().startsWith("<p>")) | 
 
 
 
 
 | 97 | description = "<p>" + description + "</p>"; | 
 
 
 
 
 | 98 | } | 
 
 
 
 
 | 99 |  | 
 
 
 
 
 | 100 | if (isLocalAvailable()) | 
 
 
 
 
 | 101 | updateLocalData(); | 
 
 
 
 
 | 102 | } | 
 
 
 
 
 | 103 |  | 
 
 
 
 
 | 104 | private void clearLocalOnlyInfo() { | 
 
 
 
 
 | 105 | aeVersion = 0; | 
 
 
 
 
 | 106 | bslInstallType = EBSLInstallType.NORMAL; | 
 
 
 
 
 | 107 |  | 
 
 
 
 
 | 108 | dependencies = new HashSet<Integer>(); | 
 
 
 
 
 | 109 | incompatibilities = new HashSet<Integer>(); | 
 
 
 
 
 | 110 | unlockLevel = new HashSet<Integer>(); | 
 
 
 
 
 | 111 |  | 
 
 
 
 
 | 112 | exeFile = null; | 
 
 
 
 
 | 113 | workingDir = null; | 
 
 
 
 
 | 114 | iconFile = null; | 
 
 
 
 
 | 115 | } | 
 
 
 
 
 | 116 |  | 
 
 
 
 
 | 117 | /** | 
 
 
 
 
 | 118 | * Update information for local package existence | 
 
 
 
 
 | 119 | */ | 
 
 
 
 
 | 120 | public void updateLocalData() { | 
 
 
 
 
 | 121 | File config = CaseInsensitiveFile.getCaseInsensitiveFile( | 
 
 
 
 
 | 122 | getLocalPath(), "Mod_Info.cfg"); | 
 
 
 
 
 | 123 | File aeicfg = new File(getLocalPath(), "aei.cfg"); | 
 
 
 
 
 | 124 | //              File plain = CaseInsensitiveFile.getCaseInsensitiveFile(getLocalPath(), | 
 
 
 
 
 | 125 | //                              "plain"); | 
 
 
 
 
 | 126 | if (config.exists()) { | 
 
 
 
 
 | 127 | Mod_Info mi = new Mod_Info(config, packageNumber); | 
 
 
 
 
 | 128 |  | 
 
 
 
 
 | 129 | aeVersion = mi.getAeVersion(); | 
 
 
 
 
 | 130 | bslInstallType = mi.getBslInstallType(); | 
 
 
 
 
 | 131 | if (isLocalOnly()) { | 
 
 
 
 
 | 132 | name = mi.getName(); | 
 
 
 
 
 | 133 | creator = mi.getCreator(); | 
 
 
 
 
 | 134 | version = mi.getVersion(); | 
 
 
 
 
 | 135 | description = mi.getDescription(); | 
 
 
 
 
 | 136 | } | 
 
 
 
 
 | 137 |  | 
 
 
 
 
 | 138 | dependencies = mi.getDependencies(); | 
 
 
 
 
 | 139 | incompatibilities = mi.getIncompatibilities(); | 
 
 
 
 
 | 140 | unlockLevel = mi.getUnlockLevel(); | 
 
 
 
 
 | 141 |  | 
 
 
 
 
 | 142 | exeFile = mi.getExeFile(); | 
 
 
 
 
 | 143 | exeType = mi.getExeType(); | 
 
 
 
 
 | 144 | workingDir = mi.getWorkingDir(); | 
 
 
 
 
 | 145 | iconFile = mi.getIconFile(); | 
 
 
 
 
 | 146 | } else { | 
 
 
 
 
 | 147 | clearLocalOnlyInfo(); | 
 
 
 
 
 | 148 | //                      System.err.println("No config found for mod folder: " | 
 
 
 
 
 | 149 | //                                      + getLocalPath().getPath()); | 
 
 
 
 
 | 150 | } | 
 
 
 
 
 | 151 | if (aeicfg.exists()) { | 
 
 
 
 
 | 152 | try { | 
 
 
 
 
 | 153 | FileInputStream fstream = new FileInputStream(aeicfg); | 
 
 
 
 
 | 154 | InputStreamReader isr = new InputStreamReader(fstream); | 
 
 
 
 
 | 155 | BufferedReader br = new BufferedReader(isr); | 
 
 
 
 
 | 156 | String strLine; | 
 
 
 
 
 | 157 | while ((strLine = br.readLine()) != null) { | 
 
 
 
 
 | 158 | if (strLine.indexOf("->") < 1) | 
 
 
 
 
 | 159 | continue; | 
 
 
 
 
 | 160 | if (strLine.indexOf("//") >= 0) | 
 
 
 
 
 | 161 | strLine = strLine.substring(0, strLine.indexOf("//")); | 
 
 
 
 
 | 162 | String[] split = strLine.split("->", 2); | 
 
 
 
 
 | 163 | String sName = split[0].trim(); | 
 
 
 
 
 | 164 | String sVal = split[1].trim(); | 
 
 
 
 
 | 165 | if (sName.equalsIgnoreCase("Timestamp")) { | 
 
 
 
 
 | 166 | localTimestamp = Long.parseLong(sVal); | 
 
 
 
 
 | 167 | } | 
 
 
 
 
 | 168 | } | 
 
 
 
 
 | 169 | isr.close(); | 
 
 
 
 
 | 170 | } catch (FileNotFoundException e) { | 
 
 
 
 
 | 171 | } catch (IOException e) { | 
 
 
 
 
 | 172 | e.printStackTrace(); | 
 
 
 
 
 | 173 | } | 
 
 
 
 
 | 174 | } | 
 
 
 
 
 | 175 | if (isLocalOnly()) { | 
 
 
 
 
 | 176 | tool = packageNumber < 10000; | 
 
 
 
 
 | 177 | } | 
 
 
 
 
 | 178 | } | 
 
 
 
 
 | 179 |  | 
 
 
 
 
 | 180 | /** | 
 
 
 
 
 | 181 | * Create a new Mod entry from the given local mod folder | 
 
 
 
 
 | 182 | * | 
 
 
 
 
 | 183 | * @param folder | 
 
 
 
 
 | 184 | *            Mod folder with Mod_Info.cfg | 
 
 
 
 
 | 185 | */ | 
 
 
 
 
 | 186 | public Package(File folder) { | 
 
 
 
 
 | 187 | packageNumber = Integer.parseInt(folder.getName().substring(0, 5)); | 
 
 
 
 
 | 188 | updateLocalData(); | 
 
 
 
 
 | 189 |  | 
 
 
 
 
 | 190 | platform = ECompatiblePlatform.BOTH; | 
 
 
 
 
 | 191 | } | 
 
 
 
 
 | 192 |  | 
 
 
 
 
 | 193 | /** | 
 
 
 
 
 | 194 | * @return has separate paths for win/mac/common or not | 
 
 
 
 
 | 195 | */ | 
 
 
 
 
 | 196 | public boolean hasSeparatePlatformDirs() { | 
 
 
 
 
 | 197 | return aeVersion >= 2; | 
 
 
 
 
 | 198 | } | 
 
 
 
 
 | 199 |  | 
 
 
 
 
 | 200 | private String getSanitizedPathName() { | 
 
 
 
 
 | 201 | return name.replaceAll("[^a-zA-Z0-9_.-]", "_"); | 
 
 
 
 
 | 202 | } | 
 
 
 
 
 | 203 |  | 
 
 
 
 
 | 204 | /** | 
 
 
 
 
 | 205 | * @return Path to local mod folder | 
 
 
 
 
 | 206 | */ | 
 
 
 
 
 | 207 | public File getLocalPath() { | 
 
 
 
 
 | 208 | final String folderStart = String.format("%05d", packageNumber); | 
 
 
 
 
 | 209 |  | 
 
 
 
 
 | 210 | if (Paths.getModsPath().exists()) { | 
 
 
 
 
 | 211 | for (File f : Paths.getModsPath().listFiles(new FilenameFilter() { | 
 
 
 
 
 | 212 | @Override | 
 
 
 
 
 | 213 | public boolean accept(File d, String fn) { | 
 
 
 
 
 | 214 | return fn.startsWith(folderStart); | 
 
 
 
 
 | 215 | } | 
 
 
 
 
 | 216 | })) { | 
 
 
 
 
 | 217 | return f; | 
 
 
 
 
 | 218 | } | 
 
 
 
 
 | 219 | } | 
 
 
 
 
 | 220 |  | 
 
 
 
 
 | 221 | return new File(Paths.getModsPath(), folderStart | 
 
 
 
 
 | 222 | + getSanitizedPathName()); | 
 
 
 
 
 | 223 | } | 
 
 
 
 
 | 224 |  | 
 
 
 
 
 | 225 | /** | 
 
 
 
 
 | 226 | * @return Is there a newer version on the depot? | 
 
 
 
 
 | 227 | */ | 
 
 
 
 
 | 228 | public boolean isNewerAvailable() { | 
 
 
 
 
 | 229 | if (!isLocalOnly()) | 
 
 
 
 
 | 230 | return updatedMillis > localTimestamp; | 
 
 
 
 
 | 231 | else | 
 
 
 
 
 | 232 | return false; | 
 
 
 
 
 | 233 | } | 
 
 
 
 
 | 234 |  | 
 
 
 
 
 | 235 | /** | 
 
 
 
 
 | 236 | * @return Mod exists within mods folder | 
 
 
 
 
 | 237 | */ | 
 
 
 
 
 | 238 | public boolean isLocalAvailable() { | 
 
 
 
 
 | 239 | return getLocalPath().exists(); | 
 
 
 
 
 | 240 | } | 
 
 
 
 
 | 241 |  | 
 
 
 
 
 | 242 | /** | 
 
 
 
 
 | 243 | * @return If this mod is only locally available (not on Depot) | 
 
 
 
 
 | 244 | */ | 
 
 
 
 
 | 245 | public boolean isLocalOnly() { | 
 
 
 
 
 | 246 | return nodeUrl == null; | 
 
 
 
 
 | 247 | } | 
 
 
 
 
 | 248 |  | 
 
 
 
 
 | 249 | /** | 
 
 
 
 
 | 250 | * @return Is mod installed? | 
 
 
 
 
 | 251 | */ | 
 
 
 
 
 | 252 | public boolean isInstalled() { | 
 
 
 
 
 | 253 | if (tool) | 
 
 
 
 
 | 254 | return ToolInstallationList.getInstance() | 
 
 
 
 
 | 255 | .isInstalled(packageNumber); | 
 
 
 
 
 | 256 | else | 
 
 
 
 
 | 257 | return PackageManager.getInstance().isModInstalled(this); | 
 
 
 
 
 | 258 | } | 
 
 
 
 
 | 259 |  | 
 
 
 
 
 | 260 | /** | 
 
 
 
 
 | 261 | * @return Name of mod | 
 
 
 
 
 | 262 | */ | 
 
 
 
 
 | 263 | public String getName() { | 
 
 
 
 
 | 264 | return name; | 
 
 
 
 
 | 265 | } | 
 
 
 
 
 | 266 |  | 
 
 
 
 
 | 267 | /** | 
 
 
 
 
 | 268 | * @return the package number | 
 
 
 
 
 | 269 | */ | 
 
 
 
 
 | 270 | public int getPackageNumber() { | 
 
 
 
 
 | 271 | return packageNumber; | 
 
 
 
 
 | 272 | } | 
 
 
 
 
 | 273 |  | 
 
 
 
 
 | 274 | /** | 
 
 
 
 
 | 275 | * @return the package number as 5 digit string | 
 
 
 
 
 | 276 | */ | 
 
 
 
 
 | 277 | public String getPackageNumberString() { | 
 
 
 
 
 | 278 | return String.format("%05d", packageNumber); | 
 
 
 
 
 | 279 | } | 
 
 
 
 
 | 280 |  | 
 
 
 
 
 | 281 | /** | 
 
 
 
 
 | 282 | * @return Types of mod | 
 
 
 
 
 | 283 | */ | 
 
 
 
 
 | 284 | public HashSet<Type> getTypes() { | 
 
 
 
 
 | 285 | return types; | 
 
 
 
 
 | 286 | } | 
 
 
 
 
 | 287 |  | 
 
 
 
 
 | 288 | /** | 
 
 
 
 
 | 289 | * @return Is this mod actually a tool? | 
 
 
 
 
 | 290 | */ | 
 
 
 
 
 | 291 | public boolean isTool() { | 
 
 
 
 
 | 292 | return tool; | 
 
 
 
 
 | 293 | } | 
 
 
 
 
 | 294 |  | 
 
 
 
 
 | 295 | /** | 
 
 
 
 
 | 296 | * @return Compatible platforms | 
 
 
 
 
 | 297 | */ | 
 
 
 
 
 | 298 | public ECompatiblePlatform getPlatform() { | 
 
 
 
 
 | 299 | return platform; | 
 
 
 
 
 | 300 | } | 
 
 
 
 
 | 301 |  | 
 
 
 
 
 | 302 | /** | 
 
 
 
 
 | 303 | * @return Version of mod | 
 
 
 
 
 | 304 | */ | 
 
 
 
 
 | 305 | public String getVersion() { | 
 
 
 
 
 | 306 | return version; | 
 
 
 
 
 | 307 | } | 
 
 
 
 
 | 308 |  | 
 
 
 
 
 | 309 | /** | 
 
 
 
 
 | 310 | * @return Submitter of mod | 
 
 
 
 
 | 311 | */ | 
 
 
 
 
 | 312 | public String getSubmitter() { | 
 
 
 
 
 | 313 | return submitter; | 
 
 
 
 
 | 314 | } | 
 
 
 
 
 | 315 |  | 
 
 
 
 
 | 316 | /** | 
 
 
 
 
 | 317 | * @return Creator of mod | 
 
 
 
 
 | 318 | */ | 
 
 
 
 
 | 319 | public String getCreator() { | 
 
 
 
 
 | 320 | return creator; | 
 
 
 
 
 | 321 | } | 
 
 
 
 
 | 322 |  | 
 
 
 
 
 | 323 | /** | 
 
 
 
 
 | 324 | * @return Installation type of BSL files | 
 
 
 
 
 | 325 | */ | 
 
 
 
 
 | 326 | public EBSLInstallType getBSLInstallType() { | 
 
 
 
 
 | 327 | return bslInstallType; | 
 
 
 
 
 | 328 | } | 
 
 
 
 
 | 329 |  | 
 
 
 
 
 | 330 | /** | 
 
 
 
 
 | 331 | * @return Description of mod | 
 
 
 
 
 | 332 | */ | 
 
 
 
 
 | 333 | public String getDescription() { | 
 
 
 
 
 | 334 | return description; | 
 
 
 
 
 | 335 | } | 
 
 
 
 
 | 336 |  | 
 
 
 
 
 | 337 | /** | 
 
 
 
 
 | 338 | * @return Size of Zip file on Depot | 
 
 
 
 
 | 339 | */ | 
 
 
 
 
 | 340 | public int getZipSize() { | 
 
 
 
 
 | 341 | return zipSize; | 
 
 
 
 
 | 342 | } | 
 
 
 
 
 | 343 |  | 
 
 
 
 
 | 344 | /** | 
 
 
 
 
 | 345 | * @return the createdMillis | 
 
 
 
 
 | 346 | */ | 
 
 
 
 
 | 347 | public long getCreatedMillis() { | 
 
 
 
 
 | 348 | return createdMillis; | 
 
 
 
 
 | 349 | } | 
 
 
 
 
 | 350 |  | 
 
 
 
 
 | 351 | /** | 
 
 
 
 
 | 352 | * @return the updatedMillis | 
 
 
 
 
 | 353 | */ | 
 
 
 
 
 | 354 | public long getUpdatedMillis() { | 
 
 
 
 
 | 355 | return updatedMillis; | 
 
 
 
 
 | 356 | } | 
 
 
 
 
 | 357 |  | 
 
 
 
 
 | 358 | /** | 
 
 
 
 
 | 359 | * @return the fileUrl | 
 
 
 
 
 | 360 | */ | 
 
 
 
 
 | 361 | public String getFileUrl() { | 
 
 
 
 
 | 362 | return fileUrl; | 
 
 
 
 
 | 363 | } | 
 
 
 
 
 | 364 |  | 
 
 
 
 
 | 365 | /** | 
 
 
 
 
 | 366 | * @return Is a package that is always installed? | 
 
 
 
 
 | 367 | */ | 
 
 
 
 
 | 368 | public boolean isCorePackage() { | 
 
 
 
 
 | 369 | return packageNumber < DepotConfig.corePackageNumberLimit; | 
 
 
 
 
 | 370 | } | 
 
 
 
 
 | 371 |  | 
 
 
 
 
 | 372 | /** | 
 
 
 
 
 | 373 | * @return Depot page URI | 
 
 
 
 
 | 374 | */ | 
 
 
 
 
 | 375 | public URI getUrl() { | 
 
 
 
 
 | 376 | return nodeUrl; | 
 
 
 
 
 | 377 | } | 
 
 
 
 
 | 378 |  | 
 
 
 
 
 | 379 | @Override | 
 
 
 
 
 | 380 | public String toString() { | 
 
 
 
 
 | 381 | return name; | 
 
 
 
 
 | 382 | } | 
 
 
 
 
 | 383 |  | 
 
 
 
 
 | 384 | /** | 
 
 
 
 
 | 385 | * @return the incompabitilities | 
 
 
 
 
 | 386 | */ | 
 
 
 
 
 | 387 | public HashSet<Integer> getIncompabitilities() { | 
 
 
 
 
 | 388 | return incompatibilities; | 
 
 
 
 
 | 389 | } | 
 
 
 
 
 | 390 |  | 
 
 
 
 
 | 391 | /** | 
 
 
 
 
 | 392 | * @return the dependencies | 
 
 
 
 
 | 393 | */ | 
 
 
 
 
 | 394 | public HashSet<Integer> getDependencies() { | 
 
 
 
 
 | 395 | return dependencies; | 
 
 
 
 
 | 396 | } | 
 
 
 
 
 | 397 |  | 
 
 
 
 
 | 398 | /** | 
 
 
 
 
 | 399 | * @return the levels this mod will unlock | 
 
 
 
 
 | 400 | */ | 
 
 
 
 
 | 401 | public HashSet<Integer> getUnlockLevels() { | 
 
 
 
 
 | 402 | return unlockLevel; | 
 
 
 
 
 | 403 | } | 
 
 
 
 
 | 404 |  | 
 
 
 
 
 | 405 | /** | 
 
 
 
 
 | 406 | * @return Executable name of this tool | 
 
 
 
 
 | 407 | */ | 
 
 
 
 
 | 408 | public File getExeFile() { | 
 
 
 
 
 | 409 | return exeFile; | 
 
 
 
 
 | 410 | } | 
 
 
 
 
 | 411 |  | 
 
 
 
 
 | 412 | /** | 
 
 
 
 
 | 413 | * @return Executable type of this tool | 
 
 
 
 
 | 414 | */ | 
 
 
 
 
 | 415 | public EExeType getExeType() { | 
 
 
 
 
 | 416 | return exeType; | 
 
 
 
 
 | 417 | } | 
 
 
 
 
 | 418 |  | 
 
 
 
 
 | 419 | /** | 
 
 
 
 
 | 420 | * @return Icon file of this tool | 
 
 
 
 
 | 421 | */ | 
 
 
 
 
 | 422 | public File getIconFile() { | 
 
 
 
 
 | 423 | return iconFile; | 
 
 
 
 
 | 424 | } | 
 
 
 
 
 | 425 |  | 
 
 
 
 
 | 426 | /** | 
 
 
 
 
 | 427 | * @return Working directory of this tool | 
 
 
 
 
 | 428 | */ | 
 
 
 
 
 | 429 | public File getWorkingDir() { | 
 
 
 
 
 | 430 | if (workingDir.equalsIgnoreCase("Exe")) { | 
 
 
 
 
 | 431 | if (exeFile != null) | 
 
 
 
 
 | 432 | return exeFile.getParentFile(); | 
 
 
 
 
 | 433 | else | 
 
 
 
 
 | 434 | return Paths.getEditionGDF(); | 
 
 
 
 
 | 435 | } else if (workingDir.equalsIgnoreCase("GDF")) | 
 
 
 
 
 | 436 | return Paths.getEditionGDF(); | 
 
 
 
 
 | 437 | else | 
 
 
 
 
 | 438 | return Paths.getEditionBasePath(); | 
 
 
 
 
 | 439 | } | 
 
 
 
 
 | 440 |  | 
 
 
 
 
 | 441 | /** | 
 
 
 
 
 | 442 | * @return Is this mod valid on the running platform? | 
 
 
 
 
 | 443 | */ | 
 
 
 
 
 | 444 | public boolean isValidOnPlatform() { | 
 
 
 
 
 | 445 | switch (platform) { | 
 
 
 
 
 | 446 | case BOTH: | 
 
 
 
 
 | 447 | return true; | 
 
 
 
 
 | 448 | case MACOS: | 
 
 
 
 
 | 449 | return (PlatformInformation.getPlatform() == Platform.MACOS); | 
 
 
 
 
 | 450 | case WIN: | 
 
 
 
 
 | 451 | return (PlatformInformation.getPlatform() == Platform.WIN) | 
 
 
 
 
 | 452 | || (PlatformInformation.getPlatform() == Platform.LINUX); | 
 
 
 
 
 | 453 | } | 
 
 
 
 
 | 454 | return false; | 
 
 
 
 
 | 455 | } | 
 
 
 
 
 | 456 |  | 
 
 
 
 
 | 457 | /** | 
 
 
 
 
 | 458 | * Delete the local package folder | 
 
 
 
 
 | 459 | */ | 
 
 
 
 
 | 460 | public void deleteLocalPackage() { | 
 
 
 
 
 | 461 | if (getLocalPath().exists()) { | 
 
 
 
 
 | 462 | try { | 
 
 
 
 
 | 463 | FileUtils.deleteDirectory(getLocalPath()); | 
 
 
 
 
 | 464 | updateLocalData(); | 
 
 
 
 
 | 465 | } catch (IOException e) { | 
 
 
 
 
 | 466 | e.printStackTrace(); | 
 
 
 
 
 | 467 | } | 
 
 
 
 
 | 468 | } | 
 
 
 
 
 | 469 | } | 
 
 
 
 
 | 470 |  | 
 
 
 
 
 | 471 | @Override | 
 
 
 
 
 | 472 | public int compareTo(Package o) { | 
 
 
 
 
 | 473 | return getPackageNumber() - o.getPackageNumber(); | 
 
 
 
 
 | 474 | } | 
 
 
 
 
 | 475 |  | 
 
 
 
 
 | 476 | } |