Fallback URL for mod list

This commit is contained in:
Anuken
2024-10-14 19:38:50 -04:00
parent 6a05ac68e1
commit 92b2a5a764
2 changed files with 44 additions and 28 deletions

View File

@ -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.*/

View File

@ -112,9 +112,15 @@ 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 -> {
if(modList != null){
listener.get(modList);
return;
}
Http.get(modJsonURLs[index], response -> {
String strResult = response.getResultAsString(); String strResult = response.getResultAsString();
Core.app.post(() -> { Core.app.post(() -> {
@ -133,14 +139,22 @@ public class ModsDialog extends BaseDialog{
modList.sortComparing(m -> parser.get(m.lastUpdated)).reverse(); modList.sortComparing(m -> parser.get(m.lastUpdated)).reverse();
listener.get(modList); listener.get(modList);
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); Log.err(e);
ui.showException(e); ui.showException(e);
} }
}); });
}, error -> Core.app.post(() -> modError(error))); }, error -> {
if(index < modJsonURLs.length - 1){
getModList(index + 1, listener);
}else{ }else{
listener.get(modList); Core.app.post(() -> {
modError(error);
if(browser != null){
browser.hide();
} }
});
}
});
} }
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;