cleanup: code cleanup
This commit is contained in:
parent
48d9626c06
commit
d9b5b3db2f
@ -35,11 +35,8 @@ public class Server {
|
|||||||
private static Integer maxLobbies;
|
private static Integer maxLobbies;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
ServerArgs serverArgs = new ServerArgs();
|
ServerArgs serverArgs = new ServerArgs();
|
||||||
JCommander jc = JCommander.newBuilder()
|
JCommander jc = JCommander.newBuilder().addObject(serverArgs).build();
|
||||||
.addObject(serverArgs)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
jc.parse(args);
|
jc.parse(args);
|
||||||
@ -55,8 +52,6 @@ public class Server {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println(serverArgs);
|
|
||||||
|
|
||||||
maxLobbies = serverArgs.getMaxLobbies();
|
maxLobbies = serverArgs.getMaxLobbies();
|
||||||
|
|
||||||
if (serverArgs.isVerbose() || serverArgs.isCheckConfig()) {
|
if (serverArgs.isVerbose() || serverArgs.isCheckConfig()) {
|
||||||
@ -67,7 +62,6 @@ public class Server {
|
|||||||
setLogLevel(serverArgs.getLogLevel());
|
setLogLevel(serverArgs.getLogLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScenarioConfig scenarioConfig = readScenarioConfig(serverArgs.getScenarioConfigFile());
|
ScenarioConfig scenarioConfig = readScenarioConfig(serverArgs.getScenarioConfigFile());
|
||||||
CharacterConfig characterConfig = readCharacterConfig(serverArgs.getCharacterConfigFile());
|
CharacterConfig characterConfig = readCharacterConfig(serverArgs.getCharacterConfigFile());
|
||||||
PartyConfig partyConfig = readPartyConfig(serverArgs.getMatchConfigFile());
|
PartyConfig partyConfig = readPartyConfig(serverArgs.getMatchConfigFile());
|
||||||
@ -76,6 +70,7 @@ public class Server {
|
|||||||
if (serverArgs.isCheckConfig()) {
|
if (serverArgs.isCheckConfig()) {
|
||||||
Logger.info("Exiting as configuration file check is done");
|
Logger.info("Exiting as configuration file check is done");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.info("populating static Server variables with config objects");
|
Logger.info("populating static Server variables with config objects");
|
||||||
@ -118,7 +113,6 @@ public class Server {
|
|||||||
map.put("writer1", "console");
|
map.put("writer1", "console");
|
||||||
map.put("writer1.level", logLevelDescriptor);
|
map.put("writer1.level", logLevelDescriptor);
|
||||||
|
|
||||||
|
|
||||||
// Add log writer 2, a file writer logging to the file server.log
|
// Add log writer 2, a file writer logging to the file server.log
|
||||||
map.put("writer2", "file");
|
map.put("writer2", "file");
|
||||||
map.put("writer2.level", logLevelDescriptor);
|
map.put("writer2.level", logLevelDescriptor);
|
||||||
@ -126,9 +120,10 @@ public class Server {
|
|||||||
|
|
||||||
Configuration.replace(map);
|
Configuration.replace(map);
|
||||||
|
|
||||||
Logger.info("Log level set to '" + logLevelDescriptor + "'");
|
Logger.info("Log level set to '{}'", logLevelDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static ScenarioConfig readScenarioConfig(File source) {
|
private static ScenarioConfig readScenarioConfig(File source) {
|
||||||
|
|
||||||
if (!source.exists()) {
|
if (!source.exists()) {
|
||||||
@ -222,6 +217,7 @@ public class Server {
|
|||||||
return config.get();
|
return config.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Returns the party configuration the server was initialized with */
|
/** Returns the party configuration the server was initialized with */
|
||||||
public static PartyConfig getPartyConfig() {
|
public static PartyConfig getPartyConfig() {
|
||||||
return partyConfig;
|
return partyConfig;
|
||||||
@ -237,6 +233,7 @@ public class Server {
|
|||||||
return characterConfig;
|
return characterConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the maximum amount of lobbies the server should create */
|
||||||
public static Integer getMaxLobbies() {
|
public static Integer getMaxLobbies() {
|
||||||
return maxLobbies;
|
return maxLobbies;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import com.beust.jcommander.Parameter;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class ServerArgs {
|
public class ServerArgs {
|
||||||
|
|
||||||
/** Whether help is requested */
|
/** Whether help is requested */
|
||||||
@Parameter(names = {"-h", "--help", "-?", "--?", "-H"}, help = true)
|
@Parameter(names = {"-h", "--help", "-?", "--?", "-H"}, help = true)
|
||||||
private boolean help;
|
private boolean help;
|
||||||
@ -90,6 +89,7 @@ public class ServerArgs {
|
|||||||
return folderPath;
|
return folderPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The maximum mount of lobbies automatically created */
|
||||||
public int getMaxLobbies() {
|
public int getMaxLobbies() {
|
||||||
return maxLobbies;
|
return maxLobbies;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user