Server cleanup

This commit is contained in:
Anuken
2019-05-13 00:43:06 -04:00
parent 83bfad3546
commit c4c4b473e5
3 changed files with 19 additions and 31 deletions

View File

@@ -25,6 +25,8 @@ import java.util.Locale;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class Vars{ public class Vars{
/** Whether to load locales.*/
public static boolean loadLocales = true;
/** IO buffer size. */ /** IO buffer size. */
public static final int bufferSize = 8192; public static final int bufferSize = 8192;
/** global charset */ /** global charset */
@@ -143,19 +145,22 @@ public class Vars{
public static void init(){ public static void init(){
Serialization.init(); Serialization.init();
//load locales if(loadLocales){
String[] stra = Core.files.internal("locales").readString().split("\n"); //load locales
locales = new Locale[stra.length]; String[] stra = Core.files.internal("locales").readString().split("\n");
for(int i = 0; i < locales.length; i++){ locales = new Locale[stra.length];
String code = stra[i]; for(int i = 0; i < locales.length; i++){
if(code.contains("_")){ String code = stra[i];
locales[i] = new Locale(code.split("_")[0], code.split("_")[1]); if(code.contains("_")){
}else{ locales[i] = new Locale(code.split("_")[0], code.split("_")[1]);
locales[i] = new Locale(code); }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(); Version.init();
content = new ContentLoader(); content = new ContentLoader();

View File

@@ -19,6 +19,7 @@ public class MindustryServer implements ApplicationListener{
@Override @Override
public void init(){ public void init(){
Core.settings.setDataDirectory(Core.files.local("config")); Core.settings.setDataDirectory(Core.files.local("config"));
loadLocales = false;
Vars.init(); Vars.init();
headless = true; headless = true;

View File

@@ -1,19 +1,10 @@
package io.anuke.mindustry.server; package io.anuke.mindustry.server;
import io.anuke.arc.ApplicationListener;
import io.anuke.arc.backends.headless.HeadlessApplication; import io.anuke.arc.backends.headless.HeadlessApplication;
import io.anuke.arc.backends.headless.HeadlessApplicationConfiguration; import io.anuke.mindustry.net.*;
import io.anuke.mindustry.net.CrashSender;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.ArcNetClient;
import io.anuke.mindustry.net.ArcNetServer;
public class ServerLauncher extends HeadlessApplication{ public class ServerLauncher{
public ServerLauncher(ApplicationListener listener, HeadlessApplicationConfiguration config){
super(listener, config);
}
public static void main(String[] args){ public static void main(String[] args){
try{ try{
@@ -21,18 +12,9 @@ public class ServerLauncher extends HeadlessApplication{
Net.setClientProvider(new ArcNetClient()); Net.setClientProvider(new ArcNetClient());
Net.setServerProvider(new ArcNetServer()); Net.setServerProvider(new ArcNetServer());
HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration(); new HeadlessApplication(new MindustryServer(args), null, throwable -> CrashSender.send(throwable, f -> {}));
new ServerLauncher(new MindustryServer(args), config);
}catch(Throwable t){ }catch(Throwable t){
CrashSender.send(t, f -> {}); 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;
}
}
} }
} }