From c324dce03464fdd861d131a64b464c3290609809 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 22 Nov 2019 16:00:53 -0500 Subject: [PATCH] Added potential global server list --- core/src/io/anuke/mindustry/Vars.java | 4 ++-- .../anuke/mindustry/ui/dialogs/JoinDialog.java | 18 ++++++++++++++++++ gradle.properties | 2 +- servers.json | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 servers.json diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index a722095c71..9f1a86db81 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -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.*/ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java index e8af992660..f828d25d7b 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java @@ -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", ""))); + }catch(Throwable t){ + t.printStackTrace(); + } + }); + }catch(Throwable t){ + t.printStackTrace(); + } + }, Throwable::printStackTrace); } private void saveServers(){ diff --git a/gradle.properties b/gradle.properties index ea6984d9ee..53d95b6898 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=e678c42cdc539e794ad0a0079a45970181aa2fe3 +archash=31a5ec0725ac679a03514c9276ceaa9895d32b95 diff --git a/servers.json b/servers.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/servers.json @@ -0,0 +1 @@ +[] \ No newline at end of file