Moved over Streamable inner classes, added test map
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package io.anuke.mindustry.server;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.core.ContentLoader;
|
||||
import io.anuke.mindustry.core.Logic;
|
||||
import io.anuke.mindustry.core.NetServer;
|
||||
import io.anuke.mindustry.core.World;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.io.BundleLoader;
|
||||
import io.anuke.ucore.modules.ModuleCore;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.server;
|
||||
|
||||
import com.badlogic.gdx.ApplicationLogger;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
@@ -49,16 +48,6 @@ public class ServerControl extends Module {
|
||||
Effects.setEffectProvider((a, b, c, d, e, f) -> {});
|
||||
Sounds.setHeadless(true);
|
||||
|
||||
//don't do anything at all for GDX logging: don't want controller info and such
|
||||
Gdx.app.setApplicationLogger(new ApplicationLogger() {
|
||||
@Override public void log(String tag, String message) { }
|
||||
@Override public void log(String tag, String message, Throwable exception) { }
|
||||
@Override public void error(String tag, String message) { }
|
||||
@Override public void error(String tag, String message, Throwable exception) { }
|
||||
@Override public void debug(String tag, String message) { }
|
||||
@Override public void debug(String tag, String message, Throwable exception) { }
|
||||
});
|
||||
|
||||
String[] commands = {};
|
||||
|
||||
if(args.length > 0){
|
||||
@@ -140,6 +129,11 @@ public class ServerControl extends Module {
|
||||
return;
|
||||
}
|
||||
|
||||
if(world.maps().all().size == 0){
|
||||
err("No maps found to host with!");
|
||||
return;
|
||||
}
|
||||
|
||||
Map result = null;
|
||||
|
||||
if(arg.length > 0) {
|
||||
@@ -230,6 +224,7 @@ public class ServerControl extends Module {
|
||||
}
|
||||
|
||||
//netCommon.sendMessage("[GRAY][[Server]:[] " + arg[0]);
|
||||
|
||||
info("&lyServer: &lb{0}", arg[0]);
|
||||
});
|
||||
|
||||
@@ -743,7 +738,23 @@ public class ServerControl extends Module {
|
||||
Response response = handler.handleMessage(line);
|
||||
|
||||
if (response.type == ResponseType.unknownCommand) {
|
||||
err("Invalid command. Type 'help' for help.");
|
||||
|
||||
int minDst = 0;
|
||||
Command closest = null;
|
||||
|
||||
for(Command command : handler.getCommandList()){
|
||||
int dst = Strings.levenshtein(command.text, response.runCommand);
|
||||
if(dst < 3 && (closest == null || dst < minDst)){
|
||||
minDst = dst;
|
||||
closest = command;
|
||||
}
|
||||
}
|
||||
|
||||
if(closest != null){
|
||||
err("Command not found. Did you mean \"" + closest.text + "\"?");
|
||||
}else {
|
||||
err("Invalid command. Type 'help' for help.");
|
||||
}
|
||||
}else if (response.type == ResponseType.fewArguments) {
|
||||
err("Too few command arguments. Usage: " + response.command.text + " " + response.command.paramText);
|
||||
}else if (response.type == ResponseType.manyArguments) {
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
package io.anuke.mindustry.server;
|
||||
|
||||
import com.badlogic.gdx.ApplicationListener;
|
||||
import com.badlogic.gdx.ApplicationLogger;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.headless.HeadlessApplication;
|
||||
import io.anuke.kryonet.KryoClient;
|
||||
import io.anuke.kryonet.KryoServer;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
|
||||
public class ServerLauncher{
|
||||
public class ServerLauncher extends HeadlessApplication{
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
Net.setClientProvider(new KryoClient());
|
||||
Net.setServerProvider(new KryoServer());
|
||||
|
||||
new HeadlessApplication(new MindustryServer(args));
|
||||
new ServerLauncher(new MindustryServer(args));
|
||||
|
||||
//find and handle uncaught exceptions in libGDX thread
|
||||
for(Thread thread : Thread.getAllStackTraces().keySet()){
|
||||
@@ -25,4 +28,18 @@ public class ServerLauncher{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ServerLauncher(ApplicationListener listener) {
|
||||
super(listener);
|
||||
|
||||
//don't do anything at all for GDX logging: don't want controller info and such
|
||||
Gdx.app.setApplicationLogger(new ApplicationLogger() {
|
||||
@Override public void log(String tag, String message) { }
|
||||
@Override public void log(String tag, String message, Throwable exception) { }
|
||||
@Override public void error(String tag, String message) { }
|
||||
@Override public void error(String tag, String message, Throwable exception) { }
|
||||
@Override public void debug(String tag, String message) { }
|
||||
@Override public void debug(String tag, String message, Throwable exception) { }
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user