mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-31 01:44:22 +07:00
Fallback URL for mod list
This commit is contained in:
parent
6a05ac68e1
commit
92b2a5a764
@ -71,10 +71,12 @@ public class Vars implements Loadable{
|
|||||||
public static final String discordURL = "https://discord.gg/mindustry";
|
public static final String discordURL = "https://discord.gg/mindustry";
|
||||||
/** URL the links to the wiki's modding guide.*/
|
/** URL the links to the wiki's modding guide.*/
|
||||||
public static final String modGuideURL = "https://mindustrygame.github.io/wiki/modding/1-modding/";
|
public static final String modGuideURL = "https://mindustrygame.github.io/wiki/modding/1-modding/";
|
||||||
/** URL to the JSON file containing all the BE servers. Only queried in BE. */
|
/** URLs to the JSON file containing all the BE servers. Only queried in BE. */
|
||||||
public static final String[] serverJsonBeURLs = {"https://raw.githubusercontent.com/Anuken/MindustryServerList/master/servers_be.json", "https://cdn.jsdelivr.net/gh/anuken/mindustryserverlist/servers_be.json"};
|
public static final String[] serverJsonBeURLs = {"https://raw.githubusercontent.com/Anuken/MindustryServerList/master/servers_be.json", "https://cdn.jsdelivr.net/gh/anuken/mindustryserverlist/servers_be.json"};
|
||||||
/** URL to the JSON file containing all the stable servers. */
|
/** URLs to the JSON file containing all the stable servers. */
|
||||||
public static final String[] serverJsonURLs = {"https://raw.githubusercontent.com/Anuken/MindustryServerList/master/servers_v8.json", "https://cdn.jsdelivr.net/gh/anuken/mindustryserverlist/servers_v8.json"};
|
public static final String[] serverJsonURLs = {"https://raw.githubusercontent.com/Anuken/MindustryServerList/master/servers_v8.json", "https://cdn.jsdelivr.net/gh/anuken/mindustryserverlist/servers_v8.json"};
|
||||||
|
/** URLs to the JSON files containing the list of mods. */
|
||||||
|
public static final String[] modJsonURLs = {"https://raw.githubusercontent.com/Anuken/MindustryMods/master/mods.json", "https://cdn.jsdelivr.net/gh/anuken/mindustrymods/mods.json"};
|
||||||
/** URL of the github issue report template.*/
|
/** URL of the github issue report template.*/
|
||||||
public static final String reportIssueURL = "https://github.com/Anuken/Mindustry/issues/new?labels=bug&template=bug_report.md";
|
public static final String reportIssueURL = "https://github.com/Anuken/Mindustry/issues/new?labels=bug&template=bug_report.md";
|
||||||
/** list of built-in servers.*/
|
/** list of built-in servers.*/
|
||||||
|
@ -112,35 +112,49 @@ public class ModsDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getModList(Cons<Seq<ModListing>> listener){
|
void getModList(int index, Cons<Seq<ModListing>> listener){
|
||||||
if(modList == null){
|
if(index >= modJsonURLs.length) return;
|
||||||
Http.get("https://raw.githubusercontent.com/Anuken/MindustryMods/master/mods.json", response -> {
|
|
||||||
String strResult = response.getResultAsString();
|
|
||||||
|
|
||||||
|
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(() -> {
|
Core.app.post(() -> {
|
||||||
try{
|
modError(error);
|
||||||
modList = JsonIO.json.fromJson(Seq.class, ModListing.class, strResult);
|
if(browser != null){
|
||||||
|
browser.hide();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, error -> Core.app.post(() -> modError(error)));
|
}
|
||||||
}else{
|
});
|
||||||
listener.get(modList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
@ -456,7 +470,7 @@ public class ModsDialog extends BaseDialog{
|
|||||||
|
|
||||||
int cols = (int)Math.max(Core.graphics.getWidth() / Scl.scl(480), 1);
|
int cols = (int)Math.max(Core.graphics.getWidth() / Scl.scl(480), 1);
|
||||||
|
|
||||||
getModList(rlistings -> {
|
getModList(0, rlistings -> {
|
||||||
browserTable.clear();
|
browserTable.clear();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user