arc.util.Http migration
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package mindustry.net;
|
||||
|
||||
import arc.*;
|
||||
import arc.Net.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.util.*;
|
||||
@@ -62,27 +61,25 @@ public class BeControl{
|
||||
|
||||
/** asynchronously checks for updates. */
|
||||
public void checkUpdate(Boolc done){
|
||||
Core.net.httpGet("https://api.github.com/repos/Anuken/MindustryBuilds/releases/latest", res -> {
|
||||
if(res.getStatus() == HttpStatus.OK){
|
||||
Jval val = Jval.read(res.getResultAsString());
|
||||
int newBuild = Strings.parseInt(val.getString("tag_name", "0"));
|
||||
if(newBuild > Version.build){
|
||||
Jval asset = val.get("assets").asArray().find(v -> v.getString("name", "").startsWith(headless ? "Mindustry-BE-Server" : "Mindustry-BE-Desktop"));
|
||||
String url = asset.getString("browser_download_url", "");
|
||||
updateAvailable = true;
|
||||
updateBuild = newBuild;
|
||||
updateUrl = url;
|
||||
Core.app.post(() -> {
|
||||
showUpdateDialog();
|
||||
done.get(true);
|
||||
});
|
||||
}else{
|
||||
Core.app.post(() -> done.get(false));
|
||||
}
|
||||
Http.get("https://api.github.com/repos/Anuken/MindustryBuilds/releases/latest")
|
||||
.error(e -> {}) //ignore errors
|
||||
.submit(res -> {
|
||||
Jval val = Jval.read(res.getResultAsString());
|
||||
int newBuild = Strings.parseInt(val.getString("tag_name", "0"));
|
||||
if(newBuild > Version.build){
|
||||
Jval asset = val.get("assets").asArray().find(v -> v.getString("name", "").startsWith(headless ? "Mindustry-BE-Server" : "Mindustry-BE-Desktop"));
|
||||
String url = asset.getString("browser_download_url", "");
|
||||
updateAvailable = true;
|
||||
updateBuild = newBuild;
|
||||
updateUrl = url;
|
||||
Core.app.post(() -> {
|
||||
showUpdateDialog();
|
||||
done.get(true);
|
||||
});
|
||||
}else{
|
||||
Core.app.post(() -> done.get(false));
|
||||
}
|
||||
}, error -> {}); //ignore errors
|
||||
});
|
||||
}
|
||||
|
||||
/** @return whether a new update is available */
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.net;
|
||||
|
||||
import arc.*;
|
||||
import arc.Net.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.struct.*;
|
||||
@@ -150,12 +149,12 @@ public class CrashSender{
|
||||
Log.info("Sending crash report.");
|
||||
|
||||
//post to crash report URL, exit code indicates send success
|
||||
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.");
|
||||
System.exit(1);
|
||||
}, t -> {
|
||||
Http.post(Vars.crashReportURL, value.toJson(OutputType.json)).error(t -> {
|
||||
Log.info("Crash report not sent.");
|
||||
System.exit(-1);
|
||||
}).block(r -> {
|
||||
Log.info("Crash sent successfully.");
|
||||
System.exit(1);
|
||||
});
|
||||
|
||||
ret();
|
||||
|
||||
Reference in New Issue
Block a user