Added potential global server list

This commit is contained in:
Anuken
2019-11-22 16:00:53 -05:00
parent 0efced4fd8
commit c324dce034
4 changed files with 22 additions and 3 deletions

View File

@ -31,8 +31,6 @@ import static io.anuke.arc.Core.*;
public class Vars implements Loadable{
/** Whether to load locales.*/
public static boolean loadLocales = true;
/** Maximum number of broken blocks. TODO implement or remove.*/
public static final int maxBrokenBlocks = 256;
/** Maximum schematic size.*/
public static final int maxSchematicSize = 32;
/** All schematic base64 starts with this string.*/
@ -51,6 +49,8 @@ public class Vars implements Loadable{
public static final String crashReportURL = "http://192.99.169.18/report";
/** URL the links to the wiki's modding guide.*/
public static final String modGuideURL = "https://mindustrygame.github.io/wiki/modding/";
/** URL to the JSON file containing all the global, public servers. */
public static final String serverJsonURL = "https://raw.githubusercontent.com/Anuken/Mindustry/master/servers.json";
/** URL the links to the wiki's modding guide.*/
public static final String reportIssueURL = "https://github.com/Anuken/Mindustry/issues/new?template=bug_report.md";
/** list of built-in servers.*/

View File

@ -9,6 +9,7 @@ import io.anuke.arc.math.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.arc.util.serialization.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.core.*;
import io.anuke.mindustry.gen.*;
@ -359,6 +360,23 @@ public class JoinDialog extends FloatingDialog{
@SuppressWarnings("unchecked")
private void loadServers(){
servers = Core.settings.getObject("server-list", Array.class, Array::new);
//get servers
Core.net.httpGet(serverJsonURL, result -> {
try{
Jval val = Jval.read(result.getResultAsString());
Core.app.post(() -> {
try{
defaultServers.clear();
val.asArray().each(child -> defaultServers.add(child.getString("address", "<invalid>")));
}catch(Throwable t){
t.printStackTrace();
}
});
}catch(Throwable t){
t.printStackTrace();
}
}, Throwable::printStackTrace);
}
private void saveServers(){

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=e678c42cdc539e794ad0a0079a45970181aa2fe3
archash=31a5ec0725ac679a03514c9276ceaa9895d32b95

1
servers.json Normal file
View File

@ -0,0 +1 @@
[]