Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
Preparing 2.1.0 update
Browse files Browse the repository at this point in the history
  • Loading branch information
skyecodes committed Sep 1, 2017
1 parent c9bfcda commit 75dc0bd
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 27 deletions.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Created by .ignore support plugin (hsz.mobi)
### Java template
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.idea/

6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</properties>
<dependencies>
<dependency>
<groupId>com.eclipsesource.minimal-json</groupId>
<artifactId>minimal-json</artifactId>
<version>0.9.4</version>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
<build>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/github/franckyi/cmpdl/CMPDL.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
public class CMPDL extends Application {

private static final String NAME = "Curse Modpack Downloader";
private static final String VERSION = "2.0.0-b3";
private static final String AUTHOR = "Franckyi (original version by Vazkii)";
private static final String VERSION = "2.1.0-b1";
private static final String AUTHOR = "Franckyi";

public static String title() {
return String.format("%s v%s by %s", NAME, VERSION, AUTHOR);
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/com/github/franckyi/cmpdl/ManifestJson.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.franckyi.cmpdl;

import com.eclipsesource.json.JsonArray;
import com.eclipsesource.json.JsonObject;
import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -18,34 +18,34 @@ public String getForgeVersion() {
return "N/A";
}

public static ManifestJson from(JsonObject root) {
public static ManifestJson from(JSONObject root) {
ManifestJson manifestJson = new ManifestJson();
MinecraftJson minecraftJson = manifestJson.new MinecraftJson();
JsonObject minecraft = root.get("minecraft").asObject();
minecraftJson.version = minecraft.getString("version", "N/A");
JSONObject minecraft = root.getJSONObject("minecraft");
minecraftJson.version = minecraft.getString("version");
minecraftJson.modLoaders = new ArrayList<>();
JsonArray modLoaders = minecraft.get("modLoaders").asArray();
JSONArray modLoaders = minecraft.getJSONArray("modLoaders");
modLoaders.iterator().forEachRemaining(jsonValue -> {
JsonObject modloader = jsonValue.asObject();
JSONObject modloader = (JSONObject) jsonValue;
MinecraftJson.ModloaderJson modloaderJson = minecraftJson.new ModloaderJson();
modloaderJson.id = modloader.getString("id", "N/A");
modloaderJson.primary = modloader.getBoolean("primary", false);
modloaderJson.id = modloader.getString("id");
modloaderJson.primary = modloader.getBoolean("primary");
minecraftJson.modLoaders.add(modloaderJson);
});
manifestJson.minecraft = minecraftJson;
manifestJson.manifestType = root.getString("manifestType", "N/A");
manifestJson.manifestVersion = root.getInt("manifestVersion", 0);
manifestJson.name = root.getString("name", "N/A");
manifestJson.version = root.getString("version", "N/A");
manifestJson.author = root.getString("author", "N/A");
manifestJson.manifestType = root.getString("manifestType");
manifestJson.manifestVersion = root.getInt("manifestVersion");
manifestJson.name = root.getString("name");
manifestJson.version = root.getString("version");
manifestJson.author = root.getString("author");
manifestJson.files = new ArrayList<>();
JsonArray files = root.get("files").asArray();
JSONArray files = root.getJSONArray("files");
files.iterator().forEachRemaining(jsonValue -> {
JsonObject file = jsonValue.asObject();
JSONObject file = (JSONObject) jsonValue;
FileJson fileJson = manifestJson.new FileJson();
fileJson.projectID = file.getInt("projectID", 0);
fileJson.fileID = file.getInt("fileID", 0);
fileJson.required = file.getBoolean("required", false);
fileJson.projectID = file.getInt("projectID");
fileJson.fileID = file.getInt("fileID");
fileJson.required = file.getBoolean("required");
manifestJson.files.add(fileJson);
});
return manifestJson;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/github/franckyi/cmpdl/task/CustomTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ String crawlAddHost(String url) throws IOException, IllegalArgumentException {
private String getLocation(String url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setInstanceFollowRedirects(false);
if (connection.getResponseCode() < 200 || connection.getResponseCode() >= 400)
throw new IOException("Error " + connection.getResponseCode() + " at " + url);
connection.getInputStream();
return connection.getHeaderField("location");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected Optional<String> call0() throws Exception {
url = new URL(modpackURL);
} catch (MalformedURLException e) {
log("The URL is malformed. This will not work !");
trace(e);
return Optional.empty();
}
protocol = url.getProtocol();
Expand All @@ -43,13 +44,14 @@ protected Optional<String> call0() throws Exception {
fileID = "latest";
}
if (host.equals("www.feed-the-beast.com") && fileID.equals("latest")) {
log("You must specify a file ID other than\n'latest' for host www.feed-the-beast.com.");
log("You must specify a file ID other than 'latest' for host www.feed-the-beast.com.");
return Optional.empty();
}
try {
return Optional.of(crawl(isCurse ? modpackURL + "/" + (fileID.equals("latest") ? "download" : fileID) : modpackURL + "/files/" + fileID + (fileID.equals("latest") ? "" : "/download")));
} catch (IOException e) {
log("The file doesn't exist or website is unreachable !");
trace(e);
return Optional.empty();
}
}
Expand Down

0 comments on commit 75dc0bd

Please sign in to comment.