From c4c4b473e56227277a5db8d717c20b7e7c020587 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 13 May 2019 00:43:06 -0400 Subject: [PATCH] Server cleanup --- core/src/io/anuke/mindustry/Vars.java | 25 +++++++++++-------- .../mindustry/server/MindustryServer.java | 1 + .../mindustry/server/ServerLauncher.java | 24 +++--------------- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index f38ac346fd..e45c036972 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -25,6 +25,8 @@ import java.util.Locale; @SuppressWarnings("unchecked") public class Vars{ + /** Whether to load locales.*/ + public static boolean loadLocales = true; /** IO buffer size. */ public static final int bufferSize = 8192; /** global charset */ @@ -143,19 +145,22 @@ public class Vars{ public static void init(){ Serialization.init(); - //load locales - String[] stra = Core.files.internal("locales").readString().split("\n"); - locales = new Locale[stra.length]; - for(int i = 0; i < locales.length; i++){ - String code = stra[i]; - if(code.contains("_")){ - locales[i] = new Locale(code.split("_")[0], code.split("_")[1]); - }else{ - locales[i] = new Locale(code); + if(loadLocales){ + //load locales + String[] stra = Core.files.internal("locales").readString().split("\n"); + locales = new Locale[stra.length]; + for(int i = 0; i < locales.length; i++){ + String code = stra[i]; + if(code.contains("_")){ + locales[i] = new Locale(code.split("_")[0], code.split("_")[1]); + }else{ + locales[i] = new Locale(code); + } } + + Arrays.sort(locales, Structs.comparing(l -> l.getDisplayName(l), String.CASE_INSENSITIVE_ORDER)); } - Arrays.sort(locales, Structs.comparing(l -> l.getDisplayName(l), String.CASE_INSENSITIVE_ORDER)); Version.init(); content = new ContentLoader(); diff --git a/server/src/io/anuke/mindustry/server/MindustryServer.java b/server/src/io/anuke/mindustry/server/MindustryServer.java index 0f61363859..37f13187b6 100644 --- a/server/src/io/anuke/mindustry/server/MindustryServer.java +++ b/server/src/io/anuke/mindustry/server/MindustryServer.java @@ -19,6 +19,7 @@ public class MindustryServer implements ApplicationListener{ @Override public void init(){ Core.settings.setDataDirectory(Core.files.local("config")); + loadLocales = false; Vars.init(); headless = true; diff --git a/server/src/io/anuke/mindustry/server/ServerLauncher.java b/server/src/io/anuke/mindustry/server/ServerLauncher.java index a6ed80333c..fcad8b324e 100644 --- a/server/src/io/anuke/mindustry/server/ServerLauncher.java +++ b/server/src/io/anuke/mindustry/server/ServerLauncher.java @@ -1,19 +1,10 @@ package io.anuke.mindustry.server; -import io.anuke.arc.ApplicationListener; import io.anuke.arc.backends.headless.HeadlessApplication; -import io.anuke.arc.backends.headless.HeadlessApplicationConfiguration; -import io.anuke.mindustry.net.CrashSender; -import io.anuke.mindustry.net.Net; -import io.anuke.mindustry.net.ArcNetClient; -import io.anuke.mindustry.net.ArcNetServer; +import io.anuke.mindustry.net.*; -public class ServerLauncher extends HeadlessApplication{ - - public ServerLauncher(ApplicationListener listener, HeadlessApplicationConfiguration config){ - super(listener, config); - } +public class ServerLauncher{ public static void main(String[] args){ try{ @@ -21,18 +12,9 @@ public class ServerLauncher extends HeadlessApplication{ Net.setClientProvider(new ArcNetClient()); Net.setServerProvider(new ArcNetServer()); - HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration(); - new ServerLauncher(new MindustryServer(args), config); + new HeadlessApplication(new MindustryServer(args), null, throwable -> CrashSender.send(throwable, f -> {})); }catch(Throwable t){ CrashSender.send(t, f -> {}); } - - //find and handle uncaught exceptions in libGDX thread - for(Thread thread : Thread.getAllStackTraces().keySet()){ - if(thread.getName().equals("HeadlessApplication")){ - thread.setUncaughtExceptionHandler((t, throwable) -> CrashSender.send(throwable, f -> {})); - break; - } - } } } \ No newline at end of file