mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-18 09:54:59 +01:00
Change RunMode and DebugMode to enums
This commit is contained in:
@@ -35,7 +35,6 @@ public final class Grasscutter {
|
||||
|
||||
private static int day; // Current day of week
|
||||
|
||||
public static RunMode MODE = RunMode.BOTH;
|
||||
private static DispatchServer dispatchServer;
|
||||
private static GameServer gameServer;
|
||||
private static PluginManager pluginManager;
|
||||
@@ -58,8 +57,6 @@ public final class Grasscutter {
|
||||
|
||||
for (String arg : args) {
|
||||
switch (arg.toLowerCase()) {
|
||||
case "-auth" -> MODE = RunMode.AUTH;
|
||||
case "-game" -> MODE = RunMode.GAME;
|
||||
case "-handbook" -> {
|
||||
Tools.createGmHandbook(); return;
|
||||
}
|
||||
@@ -85,12 +82,12 @@ public final class Grasscutter {
|
||||
gameServer = new GameServer(new InetSocketAddress(getConfig().getGameServerOptions().Ip, getConfig().getGameServerOptions().Port));
|
||||
|
||||
// Start servers.
|
||||
if(getConfig().RunMode.equalsIgnoreCase("HYBRID")) {
|
||||
if (getConfig().RunMode == ServerRunMode.HYBRID) {
|
||||
dispatchServer.start();
|
||||
gameServer.start();
|
||||
} else if (getConfig().RunMode.equalsIgnoreCase("DISPATCH_ONLY")) {
|
||||
} else if (getConfig().RunMode == ServerRunMode.DISPATCH_ONLY) {
|
||||
dispatchServer.start();
|
||||
} else if (getConfig().RunMode.equalsIgnoreCase("GAME_ONLY")) {
|
||||
} else if (getConfig().RunMode == ServerRunMode.GAME_ONLY) {
|
||||
gameServer.start();
|
||||
} else {
|
||||
getLogger().error("Invalid server run mode. " + getConfig().RunMode);
|
||||
@@ -140,7 +137,7 @@ public final class Grasscutter {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
|
||||
while ((input = br.readLine()) != null) {
|
||||
try {
|
||||
if(getConfig().RunMode.equalsIgnoreCase("DISPATCH_ONLY")) {
|
||||
if (getConfig().RunMode == ServerRunMode.DISPATCH_ONLY) {
|
||||
getLogger().error("Commands are not supported in dispatch only mode.");
|
||||
return;
|
||||
}
|
||||
@@ -154,12 +151,6 @@ public final class Grasscutter {
|
||||
Grasscutter.getLogger().error("An error occurred.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public enum RunMode {
|
||||
BOTH,
|
||||
AUTH,
|
||||
GAME
|
||||
}
|
||||
|
||||
public static Config getConfig() {
|
||||
return config;
|
||||
@@ -193,4 +184,12 @@ public final class Grasscutter {
|
||||
public static int getCurrentDayOfWeek() {
|
||||
return day;
|
||||
}
|
||||
|
||||
public enum ServerRunMode {
|
||||
HYBRID, DISPATCH_ONLY, GAME_ONLY
|
||||
}
|
||||
|
||||
public enum ServerDebugMode {
|
||||
ALL, MISSING, NONE
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user