Updated to new Arc net

This commit is contained in:
Anuken
2021-07-03 20:27:04 -04:00
parent 0b3dddcc9e
commit 3eb72d6d86
3 changed files with 6 additions and 20 deletions

View File

@@ -147,26 +147,18 @@ public class CrashSender{
ex(() -> value.addChild("javaVersion", new JsonValue(System.getProperty("java.version")))); ex(() -> value.addChild("javaVersion", new JsonValue(System.getProperty("java.version"))));
ex(() -> value.addChild("javaArch", new JsonValue(System.getProperty("sun.arch.data.model")))); ex(() -> value.addChild("javaArch", new JsonValue(System.getProperty("sun.arch.data.model"))));
boolean[] sent = {false};
Log.info("Sending crash report."); Log.info("Sending crash report.");
//post to crash report URL, exit code indicates send success //post to crash report URL, exit code indicates send success
httpPost(Vars.crashReportURL, value.toJson(OutputType.json), r -> { new arc.Net().http(new HttpRequest().block(true).method(HttpMethod.POST).content(value.toJson(OutputType.json)).url(Vars.crashReportURL), r -> {
Log.info("Crash sent successfully."); Log.info("Crash sent successfully.");
sent[0] = true;
System.exit(1); System.exit(1);
}, t -> { }, t -> {
t.printStackTrace(); Log.info("Crash report not sent.");
sent[0] = true;
System.exit(-1); System.exit(-1);
}); });
//sleep until report is sent ret();
try{
while(!sent[0]){
Thread.sleep(30);
}
}catch(InterruptedException ignored){}
}catch(Throwable death){ }catch(Throwable death){
death.printStackTrace(); death.printStackTrace();
} }
@@ -178,10 +170,6 @@ public class CrashSender{
System.exit(1); System.exit(1);
} }
private static void httpPost(String url, String content, Cons<HttpResponse> success, Cons<Throwable> failure){
new NetJavaImpl().http(new HttpRequest().method(HttpMethod.POST).content(content).url(url), success, failure);
}
private static String parseException(Throwable e){ private static String parseException(Throwable e){
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw); PrintWriter pw = new PrintWriter(sw);

View File

@@ -10,4 +10,4 @@ kapt.include.compile.classpath=false
kotlin.stdlib.default.dependency=false kotlin.stdlib.default.dependency=false
#needed for android compilation #needed for android compilation
android.useAndroidX=true android.useAndroidX=true
archash=1142cfc35b6671c6a2c5566632ff044a46527b82 archash=41de08d2d3c2f415e1965b66cf9aab3c9950477d

View File

@@ -14,9 +14,7 @@ public class GenericModTest{
static void grabMod(String url){ static void grabMod(String url){
//clear older mods //clear older mods
ApplicationTests.testDataFolder.deleteDirectory(); ApplicationTests.testDataFolder.deleteDirectory();
Core.net = new Net(); new Net().http(new HttpRequest().block(true).url(url).method(HttpMethod.GET), httpResponse -> {
Core.net.setBlock(true);
Core.net.http(new HttpRequest().url(url).method(HttpMethod.GET), httpResponse -> {
try{ try{
ApplicationTests.testDataFolder.child("mods").child("test_mod." + (url.endsWith("jar") ? "jar" : "zip")).writeBytes(Streams.copyBytes(httpResponse.getResultAsStream())); ApplicationTests.testDataFolder.child("mods").child("test_mod." + (url.endsWith("jar") ? "jar" : "zip")).writeBytes(Streams.copyBytes(httpResponse.getResultAsStream()));
}catch(IOException e){ }catch(IOException e){