9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-23 00:39:16 +00:00

some config updates

This commit is contained in:
NONPLAYT
2025-07-10 16:20:21 +03:00
parent f84d8cc1de
commit 19490233ab
10 changed files with 45 additions and 51 deletions

View File

@@ -39,11 +39,7 @@ public final class ReloadCommand extends DivineSubCommandPermission {
MinecraftServer server = ((CraftServer) sender.getServer()).getServer();
try {
DivineConfig.init((File) server.options.valueOf("divinemc-settings"));
} catch (IOException e) {
MinecraftServer.LOGGER.error("Failed to reload DivineMC config", e);
}
DivineConfig.init((File) server.options.valueOf("divinemc-settings"));
for (ServerLevel level : server.getAllLevels()) {
try {

View File

@@ -59,21 +59,30 @@ public class DivineConfig {
return convertToBukkit(config);
}
public static void init(File configFile) throws IOException {
DivineConfig.configFile = configFile;
if (configFile.exists()) {
try {
config.load(configFile);
} catch (InvalidConfigurationException e) {
throw new IOException(e);
}
}
public static void init(File configFile) {
try {
long begin = System.nanoTime();
LOGGER.info("Loading config...");
getInt("version", CONFIG_VERSION);
config.options().header(HEADER);
DivineConfig.configFile = configFile;
if (configFile.exists()) {
try {
config.load(configFile);
} catch (InvalidConfigurationException e) {
throw new IOException(e);
}
}
readConfig(DivineConfig.class, null);
checkExperimentalFeatures();
getInt("version", CONFIG_VERSION);
config.options().header(HEADER);
readConfig(DivineConfig.class, null);
checkExperimentalFeatures();
LOGGER.info("Config loaded in {}ms", (System.nanoTime() - begin) / 1_000_000);
} catch (Exception e) {
LOGGER.error("Failed to load config", e);
}
}
static void readConfig(Class<?> clazz, Object instance) throws IOException {