improved mainclass Server, and started a server for testing
This commit is contained in:
parent
03b44aeb87
commit
bd234a7849
@ -1,6 +1,7 @@
|
|||||||
package uulm.teamname.marvelous.server;
|
package uulm.teamname.marvelous.server;
|
||||||
|
|
||||||
import com.beust.jcommander.JCommander;
|
import com.beust.jcommander.JCommander;
|
||||||
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.tinylog.Logger;
|
import org.tinylog.Logger;
|
||||||
import org.tinylog.configuration.Configuration;
|
import org.tinylog.configuration.Configuration;
|
||||||
import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig;
|
import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig;
|
||||||
@ -32,14 +33,21 @@ public class Server {
|
|||||||
|
|
||||||
ServerArgs serverArgs = new ServerArgs();
|
ServerArgs serverArgs = new ServerArgs();
|
||||||
|
|
||||||
JCommander.newBuilder()
|
try {
|
||||||
.addObject(serverArgs)
|
JCommander.newBuilder()
|
||||||
.build()
|
.addObject(serverArgs)
|
||||||
.parse(args);
|
.build()
|
||||||
|
.parse(args);
|
||||||
|
} catch (ParameterException e) {
|
||||||
|
Logger.error("Invalid parameters: {}", e.getMessage());
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println(serverArgs);
|
System.out.println(serverArgs);
|
||||||
|
|
||||||
if (serverArgs.isVerbose()) {
|
if (serverArgs.isVerbose() || serverArgs.isCheckConfig()) {
|
||||||
|
// If checkConfig, the LogLevel is also set to max, because more information
|
||||||
|
// is exactly what checking the requirements means
|
||||||
setLogLevel(5);
|
setLogLevel(5);
|
||||||
} else {
|
} else {
|
||||||
setLogLevel(serverArgs.getLogLevel());
|
setLogLevel(serverArgs.getLogLevel());
|
||||||
@ -50,9 +58,22 @@ public class Server {
|
|||||||
CharacterConfig characterConfig = readCharacterConfig(serverArgs.getCharacterConfigFile());
|
CharacterConfig characterConfig = readCharacterConfig(serverArgs.getCharacterConfigFile());
|
||||||
PartyConfig partyConfig = readPartyConfig(serverArgs.getMatchConfigFile());
|
PartyConfig partyConfig = readPartyConfig(serverArgs.getMatchConfigFile());
|
||||||
|
|
||||||
InetSocketAddress address = new InetSocketAddress(serverArgs.getPort());
|
// If only configurations should be checked, the server exits here
|
||||||
|
if (serverArgs.isCheckConfig()) {
|
||||||
|
Logger.info("Exiting as configuration file check is done");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
InetSocketAddress address = new InetSocketAddress("localhost", serverArgs.getPort());
|
||||||
Logger.trace("Inet address {} created", address);
|
Logger.trace("Inet address {} created", address);
|
||||||
|
|
||||||
|
var json = new JSON(characterConfig);
|
||||||
|
Logger.trace("New JSON instance created with characterConfig");
|
||||||
|
|
||||||
|
MarvelousServer netConnector = new MarvelousServer(address, json);
|
||||||
|
System.out.println("Starting server");
|
||||||
|
netConnector.start();
|
||||||
|
System.out.println("Server started");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user