cleanup: code cleanup

This commit is contained in:
punchready 2021-06-07 03:49:06 +02:00
parent 48d9626c06
commit d9b5b3db2f
2 changed files with 7 additions and 10 deletions

View File

@ -35,11 +35,8 @@ public class Server {
private static Integer maxLobbies;
public static void main(String[] args) {
ServerArgs serverArgs = new ServerArgs();
JCommander jc = JCommander.newBuilder()
.addObject(serverArgs)
.build();
JCommander jc = JCommander.newBuilder().addObject(serverArgs).build();
try {
jc.parse(args);
@ -55,8 +52,6 @@ public class Server {
return;
}
// System.out.println(serverArgs);
maxLobbies = serverArgs.getMaxLobbies();
if (serverArgs.isVerbose() || serverArgs.isCheckConfig()) {
@ -67,7 +62,6 @@ public class Server {
setLogLevel(serverArgs.getLogLevel());
}
ScenarioConfig scenarioConfig = readScenarioConfig(serverArgs.getScenarioConfigFile());
CharacterConfig characterConfig = readCharacterConfig(serverArgs.getCharacterConfigFile());
PartyConfig partyConfig = readPartyConfig(serverArgs.getMatchConfigFile());
@ -76,6 +70,7 @@ public class Server {
if (serverArgs.isCheckConfig()) {
Logger.info("Exiting as configuration file check is done");
System.exit(0);
return;
}
Logger.info("populating static Server variables with config objects");
@ -118,7 +113,6 @@ public class Server {
map.put("writer1", "console");
map.put("writer1.level", logLevelDescriptor);
// Add log writer 2, a file writer logging to the file server.log
map.put("writer2", "file");
map.put("writer2.level", logLevelDescriptor);
@ -126,9 +120,10 @@ public class Server {
Configuration.replace(map);
Logger.info("Log level set to '" + logLevelDescriptor + "'");
Logger.info("Log level set to '{}'", logLevelDescriptor);
}
private static ScenarioConfig readScenarioConfig(File source) {
if (!source.exists()) {
@ -222,6 +217,7 @@ public class Server {
return config.get();
}
/** Returns the party configuration the server was initialized with */
public static PartyConfig getPartyConfig() {
return partyConfig;
@ -237,6 +233,7 @@ public class Server {
return characterConfig;
}
/** Returns the maximum amount of lobbies the server should create */
public static Integer getMaxLobbies() {
return maxLobbies;
}

View File

@ -5,7 +5,6 @@ import com.beust.jcommander.Parameter;
import java.io.File;
public class ServerArgs {
/** Whether help is requested */
@Parameter(names = {"-h", "--help", "-?", "--?", "-H"}, help = true)
private boolean help;
@ -90,6 +89,7 @@ public class ServerArgs {
return folderPath;
}
/** The maximum mount of lobbies automatically created */
public int getMaxLobbies() {
return maxLobbies;
}