Fallback URL for mod list
This commit is contained in:
@@ -112,35 +112,49 @@ public class ModsDialog extends BaseDialog{
|
||||
}
|
||||
}
|
||||
|
||||
void getModList(Cons<Seq<ModListing>> listener){
|
||||
if(modList == null){
|
||||
Http.get("https://raw.githubusercontent.com/Anuken/MindustryMods/master/mods.json", response -> {
|
||||
String strResult = response.getResultAsString();
|
||||
void getModList(int index, Cons<Seq<ModListing>> listener){
|
||||
if(index >= modJsonURLs.length) return;
|
||||
|
||||
if(modList != null){
|
||||
listener.get(modList);
|
||||
return;
|
||||
}
|
||||
|
||||
Http.get(modJsonURLs[index], response -> {
|
||||
String strResult = response.getResultAsString();
|
||||
|
||||
Core.app.post(() -> {
|
||||
try{
|
||||
modList = JsonIO.json.fromJson(Seq.class, ModListing.class, strResult);
|
||||
|
||||
var d = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
Func<String, Date> parser = text -> {
|
||||
try{
|
||||
return d.parse(text);
|
||||
}catch(Exception e){
|
||||
return new Date();
|
||||
}
|
||||
};
|
||||
|
||||
modList.sortComparing(m -> parser.get(m.lastUpdated)).reverse();
|
||||
listener.get(modList);
|
||||
}catch(Exception e){
|
||||
Log.err(e);
|
||||
ui.showException(e);
|
||||
}
|
||||
});
|
||||
}, error -> {
|
||||
if(index < modJsonURLs.length - 1){
|
||||
getModList(index + 1, listener);
|
||||
}else{
|
||||
Core.app.post(() -> {
|
||||
try{
|
||||
modList = JsonIO.json.fromJson(Seq.class, ModListing.class, strResult);
|
||||
|
||||
var d = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
Func<String, Date> parser = text -> {
|
||||
try{
|
||||
return d.parse(text);
|
||||
}catch(Exception e){
|
||||
return new Date();
|
||||
}
|
||||
};
|
||||
|
||||
modList.sortComparing(m -> parser.get(m.lastUpdated)).reverse();
|
||||
listener.get(modList);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
ui.showException(e);
|
||||
modError(error);
|
||||
if(browser != null){
|
||||
browser.hide();
|
||||
}
|
||||
});
|
||||
}, error -> Core.app.post(() -> modError(error)));
|
||||
}else{
|
||||
listener.get(modList);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setup(){
|
||||
@@ -456,7 +470,7 @@ public class ModsDialog extends BaseDialog{
|
||||
|
||||
int cols = (int)Math.max(Core.graphics.getWidth() / Scl.scl(480), 1);
|
||||
|
||||
getModList(rlistings -> {
|
||||
getModList(0, rlistings -> {
|
||||
browserTable.clear();
|
||||
int i = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user