1.0.6
All checks were successful
ModUpdater/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-06-24 21:54:28 -04:00
parent c3c45a033e
commit 4199aa02bb
7 changed files with 49 additions and 37 deletions

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
**1.0.6**
* Fix Crash (Again)
**1.0.5** **1.0.5**
* Fix Crash * Fix Crash

View File

@ -34,6 +34,7 @@ dependencies {
shadowJar { shadowJar {
configurations = [project.configurations.shadow] configurations = [project.configurations.shadow]
classifier 'shadow-dev' classifier 'shadow-dev'
mergeServiceFiles()
} }
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation

View File

@ -9,7 +9,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.8.8+build.202 fabric_loader_version = 0.8.8+build.202
# Mod Properties # Mod Properties
mod_version = 1.0.5 mod_version = 1.0.6
maven_group = com.thebrokenrail maven_group = com.thebrokenrail
# Dependencies # Dependencies

View File

@ -33,18 +33,21 @@ class CurseForgeStrategy implements ModUpdateStrategy {
return null; return null;
} }
String data = Util.urlToString("https://addons-ecs.forgesvc.net/api/v2/addon/" + projectID + "/files"); String data;
Moshi moshi = new Moshi.Builder().build();
JsonAdapter<CurseForgeFile[]> jsonAdapter = moshi.adapter(CurseForgeFile[].class);
CurseForgeFile[] files;
try { try {
files = jsonAdapter.fromJson(data); data = Util.urlToString("https://addons-ecs.forgesvc.net/api/v2/addon/" + projectID + "/files");
} catch (IOException e) { } catch (IOException e) {
ModUpdater.getLogger().warn("Unable To Access CurseForge: " + name); ModUpdater.getLogger().warn("Unable To Access CurseForge: " + name);
return null; return null;
} catch (JsonDataException e) { }
CurseForgeFile[] files;
try {
Moshi moshi = new Moshi.Builder().build();
JsonAdapter<CurseForgeFile[]> jsonAdapter = moshi.adapter(CurseForgeFile[].class);
files = jsonAdapter.fromJson(data);
} catch (JsonDataException | IOException e) {
ModUpdater.getLogger().warn("CurseForge Sent Invalid Data: ", e); ModUpdater.getLogger().warn("CurseForge Sent Invalid Data: ", e);
return null; return null;
} }

View File

@ -37,19 +37,22 @@ public class GitHubReleasesStrategy implements ModUpdateStrategy {
return null; return null;
} }
String data = Util.urlToString(String.format("https://api.github.com/repos/%s/%s/releases", owner, repo)); String data;
Moshi moshi = new Moshi.Builder().build();
JsonAdapter<GitHubRelease[]> jsonAdapter = moshi.adapter(GitHubRelease[].class);
GitHubRelease[] releases;
try { try {
// GitHub's API never omits values, they're always null data = Util.urlToString(String.format("https://api.github.com/repos/%s/%s/releases", owner, repo));
releases = jsonAdapter.nonNull().fromJson(data);
} catch (IOException e) { } catch (IOException e) {
ModUpdater.getLogger().warn("Unable To Access GitHub: " + name); ModUpdater.getLogger().warn("Unable To Access GitHub: " + name);
return null; return null;
} catch (JsonDataException e) { }
GitHubRelease[] releases;
try {
Moshi moshi = new Moshi.Builder().build();
JsonAdapter<GitHubRelease[]> jsonAdapter = moshi.adapter(GitHubRelease[].class);
// GitHub's API never omits values, they're always null
releases = jsonAdapter.nonNull().fromJson(data);
} catch (JsonDataException | IOException e) {
ModUpdater.getLogger().warn("GitHub Sent Invalid Data: ", e); ModUpdater.getLogger().warn("GitHub Sent Invalid Data: ", e);
return null; return null;
} }

View File

@ -12,8 +12,7 @@ import org.dom4j.DocumentException;
import org.dom4j.Node; import org.dom4j.Node;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import java.net.MalformedURLException; import java.io.IOException;
import java.net.URL;
import java.util.List; import java.util.List;
public class MavenStrategy implements ModUpdateStrategy { public class MavenStrategy implements ModUpdateStrategy {
@ -33,11 +32,19 @@ public class MavenStrategy implements ModUpdateStrategy {
String mavenRoot = String.format("%s/%s/%s", repository, group.replaceAll("\\.", "/"), artifact); String mavenRoot = String.format("%s/%s/%s", repository, group.replaceAll("\\.", "/"), artifact);
String data;
try {
data = Util.urlToString(mavenRoot + "/maven-metadata.xml");
} catch (IOException e) {
ModUpdater.getLogger().warn("Unable To Access Maven Repository: " + name);
return null;
}
Document doc; Document doc;
try { try {
SAXReader reader = new SAXReader(); SAXReader reader = new SAXReader();
doc = reader.read(new URL(mavenRoot + "/maven-metadata.xml")); doc = reader.read(data);
} catch (MalformedURLException | DocumentException e) { } catch (DocumentException e) {
ModUpdater.getLogger().warn("Unable To Access Maven Repository: " + name); ModUpdater.getLogger().warn("Unable To Access Maven Repository: " + name);
return null; return null;
} }

View File

@ -12,24 +12,19 @@ import java.net.URL;
import java.util.Optional; import java.util.Optional;
public class Util { public class Util {
public static String urlToString(String urlStr) { public static String urlToString(String urlStr) throws IOException {
try { StringBuilder stringBuilder = new StringBuilder();
StringBuilder stringBuilder = new StringBuilder(); URL url = new URL(urlStr);
URL url = new URL(urlStr);
try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()))) { try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()))) {
String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
stringBuilder.append(line); stringBuilder.append(line);
stringBuilder.append('\n'); stringBuilder.append('\n');
}
} }
return stringBuilder.toString();
} catch (IOException e) {
e.printStackTrace();
return "";
} }
return stringBuilder.toString();
} }
public static final String JAR_EXTENSION = ".jar"; public static final String JAR_EXTENSION = ".jar";