mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-15 16:34:56 +01:00
Merge development into plugin-auth
This commit is contained in:
@@ -34,6 +34,7 @@ import emu.grasscutter.utils.Language;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
import emu.grasscutter.tools.Tools;
|
||||
import emu.grasscutter.utils.Crypto;
|
||||
import emu.grasscutter.BuildConfig;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -88,6 +89,9 @@ public final class Grasscutter {
|
||||
case "-gachamap" -> {
|
||||
Tools.createGachaMapping(DATA("gacha_mappings.js")); exitEarly = true;
|
||||
}
|
||||
case "-version" -> {
|
||||
System.out.println("Grasscutter version: " + BuildConfig.VERSION + "-" + BuildConfig.GIT_HASH); exitEarly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +130,9 @@ public final class Grasscutter {
|
||||
httpServer.addRouter(DispatchHandler.class);
|
||||
httpServer.addRouter(LegacyAuthHandler.class);
|
||||
httpServer.addRouter(GachaHandler.class);
|
||||
|
||||
// TODO: find a better place?
|
||||
StaminaManager.initialize();
|
||||
|
||||
// Start servers.
|
||||
var runMode = SERVER.runMode;
|
||||
@@ -178,16 +185,21 @@ public final class Grasscutter {
|
||||
* Attempts to load the configuration from a file.
|
||||
*/
|
||||
public static void loadConfig() {
|
||||
// Check if config.json exists. If not, we generate a new config.
|
||||
if (!configFile.exists()) {
|
||||
getLogger().info("config.json could not be found. Generating a default configuration ...");
|
||||
config = new ConfigContainer();
|
||||
Grasscutter.saveConfig(config);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the file already exists, we attempt to load it.
|
||||
try (FileReader file = new FileReader(configFile)) {
|
||||
config = gson.fromJson(file, ConfigContainer.class);
|
||||
} catch (Exception exception) {
|
||||
Grasscutter.saveConfig(null);
|
||||
config = new ConfigContainer();
|
||||
} catch (Error error) {
|
||||
// Occurred probably from an outdated config file.
|
||||
Grasscutter.saveConfig(null);
|
||||
config = new ConfigContainer();
|
||||
}
|
||||
getLogger().error("There was an error while trying to load the configuration from config.json. Please make sure that there are no syntax errors. If you want to start with a default configuration, delete your existing config.json.");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user