mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-31 01:44:22 +07:00
Added fallback URLs for server list
This commit is contained in:
parent
3545ed100c
commit
c2405a882c
@ -72,9 +72,9 @@ public class Vars implements Loadable{
|
||||
/** URL the links to the wiki's modding guide.*/
|
||||
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. */
|
||||
public static final String serverJsonBeURL = "https://raw.githubusercontent.com/Anuken/MindustryServerList/master/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. */
|
||||
public static final String serverJsonURL = "https://raw.githubusercontent.com/Anuken/MindustryServerList/master/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"};
|
||||
/** 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";
|
||||
/** list of built-in servers.*/
|
||||
|
@ -631,12 +631,24 @@ public class JoinDialog extends BaseDialog{
|
||||
Core.settings.remove("server-list");
|
||||
}
|
||||
|
||||
var url = Version.type.equals("bleeding-edge") || Vars.forceBeServers ? serverJsonBeURL : serverJsonURL;
|
||||
Log.info("Fetching community servers at @", url);
|
||||
var urls = Version.type.equals("bleeding-edge") || Vars.forceBeServers ? serverJsonBeURLs : serverJsonURLs;
|
||||
|
||||
fetchServers(urls, 0);
|
||||
}
|
||||
|
||||
private void fetchServers(String[] urls, int index){
|
||||
if(index >= urls.length) return;
|
||||
|
||||
//get servers
|
||||
Http.get(url)
|
||||
.error(t -> Log.err("Failed to fetch community servers", t))
|
||||
Http.get(urls[index])
|
||||
.error(t -> {
|
||||
if(index < urls.length - 1){
|
||||
//attempt fetching from the next URL upon failure
|
||||
fetchServers(urls, index + 1);
|
||||
}else{
|
||||
Log.err("Failed to fetch community servers", t);
|
||||
}
|
||||
})
|
||||
.submit(result -> {
|
||||
Jval val = Jval.read(result.getResultAsString());
|
||||
Seq<ServerGroup> servers = new Seq<>();
|
||||
|
Loading…
Reference in New Issue
Block a user