mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-06-07 02:07:26 +08:00
Format code [skip actions]
This commit is contained in:
@@ -1,73 +1,78 @@
|
||||
package emu.grasscutter.utils;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.*;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import emu.grasscutter.BuildConfig;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.net.packet.PacketOpcodesUtils;
|
||||
import emu.grasscutter.tools.Dumpers;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.*;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/** A parser for start-up arguments. */
|
||||
public final class StartupArguments {
|
||||
/* A map of parameter -> argument handler. */
|
||||
private static final Map<String, Function<String, Boolean>> argumentHandlers = new HashMap<>() {
|
||||
{
|
||||
putAll(Map.of("-dumppacketids",
|
||||
parameter -> {
|
||||
PacketOpcodesUtils.dumpPacketIds();
|
||||
return true;
|
||||
},
|
||||
"-version", StartupArguments::printVersion,
|
||||
"-debug", StartupArguments::enableDebug,
|
||||
"-lang",
|
||||
parameter -> {
|
||||
Grasscutter.setPreferredLanguage(parameter);
|
||||
return false;
|
||||
},
|
||||
"-game",
|
||||
parameter -> {
|
||||
Grasscutter.setRunModeOverride(Grasscutter.ServerRunMode.GAME_ONLY);
|
||||
return false;
|
||||
},
|
||||
"-dispatch",
|
||||
parameter -> {
|
||||
Grasscutter.setRunModeOverride(Grasscutter.ServerRunMode.DISPATCH_ONLY);
|
||||
return false;
|
||||
},
|
||||
"-noconsole",
|
||||
parameter -> {
|
||||
Grasscutter.setNoConsole(true);
|
||||
return false;
|
||||
},
|
||||
"-test",
|
||||
parameter -> {
|
||||
// Disable the console.
|
||||
SERVER.game.enableConsole = false;
|
||||
// Disable HTTP encryption.
|
||||
SERVER.http.encryption.useEncryption = false;
|
||||
return false;
|
||||
},
|
||||
"-dump", StartupArguments::dump,
|
||||
private static final Map<String, Function<String, Boolean>> argumentHandlers =
|
||||
new HashMap<>() {
|
||||
{
|
||||
putAll(
|
||||
Map.of(
|
||||
"-dumppacketids",
|
||||
parameter -> {
|
||||
PacketOpcodesUtils.dumpPacketIds();
|
||||
return true;
|
||||
},
|
||||
"-version",
|
||||
StartupArguments::printVersion,
|
||||
"-debug",
|
||||
StartupArguments::enableDebug,
|
||||
"-lang",
|
||||
parameter -> {
|
||||
Grasscutter.setPreferredLanguage(parameter);
|
||||
return false;
|
||||
},
|
||||
"-game",
|
||||
parameter -> {
|
||||
Grasscutter.setRunModeOverride(Grasscutter.ServerRunMode.GAME_ONLY);
|
||||
return false;
|
||||
},
|
||||
"-dispatch",
|
||||
parameter -> {
|
||||
Grasscutter.setRunModeOverride(Grasscutter.ServerRunMode.DISPATCH_ONLY);
|
||||
return false;
|
||||
},
|
||||
"-noconsole",
|
||||
parameter -> {
|
||||
Grasscutter.setNoConsole(true);
|
||||
return false;
|
||||
},
|
||||
"-test",
|
||||
parameter -> {
|
||||
// Disable the console.
|
||||
SERVER.game.enableConsole = false;
|
||||
// Disable HTTP encryption.
|
||||
SERVER.http.encryption.useEncryption = false;
|
||||
return false;
|
||||
},
|
||||
"-dump",
|
||||
StartupArguments::dump,
|
||||
|
||||
// Aliases.
|
||||
"-v", StartupArguments::printVersion
|
||||
));
|
||||
putAll(Map.of(
|
||||
"-debugall",
|
||||
parameter -> {
|
||||
StartupArguments.enableDebug("all");
|
||||
return false;
|
||||
// Aliases.
|
||||
"-v",
|
||||
StartupArguments::printVersion));
|
||||
putAll(
|
||||
Map.of(
|
||||
"-debugall",
|
||||
parameter -> {
|
||||
StartupArguments.enableDebug("all");
|
||||
return false;
|
||||
}));
|
||||
}
|
||||
));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
private StartupArguments() {
|
||||
// This class is not meant to be instantiated.
|
||||
|
||||
Reference in New Issue
Block a user