diff --git a/divinemc-server/minecraft-patches/features/0002-Configuration.patch b/divinemc-server/minecraft-patches/features/0002-Configuration.patch index 296c93f..60265fb 100644 --- a/divinemc-server/minecraft-patches/features/0002-Configuration.patch +++ b/divinemc-server/minecraft-patches/features/0002-Configuration.patch @@ -27,7 +27,7 @@ index 4f90ebcd86fba38dec313143e36614e992c7dbc7..959d87f4cd1efe8cf591e98c7d327280 this.setPvpAllowed(properties.pvp); diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 0fe8f4601eedfa68c38ebadc7847ba7a07ff6fb6..3856bbe579ef6df2f220c46bc69461cab026a131 100644 +index 0fe8f4601eedfa68c38ebadc7847ba7a07ff6fb6..b4c2602ecf6b943ab022866231f74b850269af8f 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -171,6 +171,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -38,11 +38,18 @@ index 0fe8f4601eedfa68c38ebadc7847ba7a07ff6fb6..3856bbe579ef6df2f220c46bc69461ca public static BlockPos lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; private org.spigotmc.TickLimiter tileLimiter; -@@ -898,6 +899,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -898,6 +899,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.purpurConfig = new org.purpurmc.purpur.PurpurWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), env); // Purpur - Purpur config files -+ this.divineConfig = new org.bxteam.divinemc.DivineWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), env); // DivineMC - Configuration ++ // DivineMC start - Configuration ++ try { ++ this.divineConfig = new org.bxteam.divinemc.DivineWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), env); ++ } catch (java.io.IOException e) { ++ net.minecraft.server.MinecraftServer.LOGGER.error("Failed to load DivineMC configuration for world '{}'", ((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), e); ++ throw new RuntimeException(e); ++ } ++ // DivineMC end - Configuration this.playerBreedingCooldowns = this.getNewBreedingCooldownCache(); // Purpur - Add adjustable breeding cooldown to config this.generator = gen; this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); diff --git a/divinemc-server/minecraft-patches/features/0008-Parallel-world-ticking.patch b/divinemc-server/minecraft-patches/features/0008-Parallel-world-ticking.patch index 027468b..5a7ac22 100644 --- a/divinemc-server/minecraft-patches/features/0008-Parallel-world-ticking.patch +++ b/divinemc-server/minecraft-patches/features/0008-Parallel-world-ticking.patch @@ -370,7 +370,7 @@ index 959d87f4cd1efe8cf591e98c7d32728067f7117c..697f690305db56ae5a05483aae37994d try { org.purpurmc.purpur.PurpurConfig.init((java.io.File) options.valueOf("purpur-settings")); diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 5d2483b2d59ae246b822d73b9996c2aa86623ab1..92f3e5d929997a974c367ec3ce02cda4acdb5183 100644 +index fad9cf255cbb222f0bf80f5e8126fed3cf033b1f..59c24ebf12fa8a370750c265be7618eac689f2ff 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -184,7 +184,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -599,7 +599,7 @@ index 264b713e8b7c3d5f7d8e1facc90a60349f2cf414..f461b060e03edf4102290a424ab008b8 serverLevel.capturedBlockStates.clear(); org.bukkit.event.world.StructureGrowEvent structureEvent = null; diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a76c83e98 100644 +index b4c2602ecf6b943ab022866231f74b850269af8f..ad80b2fe21a09f070bc5e299e18533c2ec811ca3 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -172,6 +172,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -610,7 +610,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a public static BlockPos lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; private org.spigotmc.TickLimiter tileLimiter; -@@ -1146,6 +1147,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1153,6 +1154,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { @@ -618,7 +618,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a // CraftBukkit start - tree generation if (this.captureTreeGeneration) { // Paper start - Protect Bedrock and End Portal/Frames from being destroyed -@@ -1530,7 +1532,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1537,7 +1539,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl tickingBlockEntity.tick(); // Paper start - rewrite chunk system if ((++tickedEntities & 7) == 0) { @@ -627,7 +627,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a } // Paper end - rewrite chunk system } -@@ -1553,7 +1555,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1560,7 +1562,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Paper end - Prevent block entity and entity crashes } @@ -636,7 +636,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a } // Paper start - Option to prevent armor stands from doing entity lookups -@@ -1696,6 +1698,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1703,6 +1705,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Nullable public BlockEntity getBlockEntity(BlockPos pos, boolean validate) { @@ -644,7 +644,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a // Paper start - Perf: Optimize capturedTileEntities lookup net.minecraft.world.level.block.entity.BlockEntity blockEntity; if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(pos)) != null) { -@@ -1713,6 +1716,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1720,6 +1723,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } public void setBlockEntity(BlockEntity blockEntity) { @@ -652,7 +652,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a BlockPos blockPos = blockEntity.getBlockPos(); if (!this.isOutsideBuildHeight(blockPos)) { // CraftBukkit start -@@ -1797,6 +1801,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1804,6 +1808,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public List getEntities(@Nullable Entity entity, AABB boundingBox, Predicate predicate) { @@ -660,7 +660,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a Profiler.get().incrementCounter("getEntities"); List list = Lists.newArrayList(); -@@ -2109,8 +2114,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -2116,8 +2121,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public abstract RecipeAccess recipeAccess(); public BlockPos getBlockRandomPos(int x, int y, int z, int yMask) { diff --git a/divinemc-server/minecraft-patches/features/0025-Re-Fix-MC-117075.patch b/divinemc-server/minecraft-patches/features/0025-Re-Fix-MC-117075.patch index 6310c67..c1314f0 100644 --- a/divinemc-server/minecraft-patches/features/0025-Re-Fix-MC-117075.patch +++ b/divinemc-server/minecraft-patches/features/0025-Re-Fix-MC-117075.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Re-Fix MC-117075 diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 8f37c27bba829733fb8db5f35470092a76c83e98..595ebb40f47dd55127c630813813d21d8a1274cd 100644 +index ad80b2fe21a09f070bc5e299e18533c2ec811ca3..7c80f90ccab0f90a4c76c2d195f4aaa0b12deb9a 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -115,7 +115,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -17,7 +17,7 @@ index 8f37c27bba829733fb8db5f35470092a76c83e98..595ebb40f47dd55127c630813813d21d protected final NeighborUpdater neighborUpdater; private final List pendingBlockEntityTickers = Lists.newArrayList(); private boolean tickingBlockEntities; -@@ -1527,7 +1527,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1534,7 +1534,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl TickingBlockEntity tickingBlockEntity = this.blockEntityTickers.get(this.tileTickPosition); // Spigot end if (tickingBlockEntity.isRemoved()) { @@ -26,7 +26,7 @@ index 8f37c27bba829733fb8db5f35470092a76c83e98..595ebb40f47dd55127c630813813d21d } else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) { tickingBlockEntity.tick(); // Paper start - rewrite chunk system -@@ -1539,6 +1539,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1546,6 +1546,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 diff --git a/divinemc-server/paper-patches/features/0002-Configuration.patch b/divinemc-server/paper-patches/features/0002-Configuration.patch index d6c11c2..f4d4427 100644 --- a/divinemc-server/paper-patches/features/0002-Configuration.patch +++ b/divinemc-server/paper-patches/features/0002-Configuration.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configuration diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 6a08a42acdb2ee24b5e403b15fb825f3cb49c968..f4f2473aa844bb245156e391df9f1997bf2013f5 100644 +index 6a08a42acdb2ee24b5e403b15fb825f3cb49c968..e51fd95bad5038ec7c1b85babf29799d443f9b8b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1103,6 +1103,13 @@ public final class CraftServer implements Server { @@ -22,16 +22,22 @@ index 6a08a42acdb2ee24b5e403b15fb825f3cb49c968..f4f2473aa844bb245156e391df9f1997 for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) -@@ -1119,6 +1126,7 @@ public final class CraftServer implements Server { +@@ -1119,6 +1126,13 @@ public final class CraftServer implements Server { } world.spigotConfig.init(); // Spigot world.purpurConfig.init(); // Purpur - Purpur config files -+ world.divineConfig.init(); // DivineMC - Configuration ++ // DivineMC start - Configuration ++ try { ++ world.divineConfig.init(); ++ } catch (IOException e) { ++ this.logger.log(Level.WARNING, "Failed to reload DivineMC configuration for world " + world.dimension().location(), e); ++ } ++ // DivineMC end - Configuration } Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index bab0d25e82f85c7b9524ae42e0bb41e6233d71cf..f367efa0afae9792f87a842dfe7ba098a3ce7f2d 100644 +index bab0d25e82f85c7b9524ae42e0bb41e6233d71cf..f263987076d352dbf6e4bb5c57a35a4593088bae 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -183,6 +183,15 @@ public class Main { @@ -43,7 +49,7 @@ index bab0d25e82f85c7b9524ae42e0bb41e6233d71cf..f367efa0afae9792f87a842dfe7ba098 + acceptsAll(asList("divinemc", "divinemc-settings"), "File for DivineMC settings") + .withRequiredArg() + .ofType(File.class) -+ .defaultsTo(new File("divinemc.yml")) ++ .defaultsTo(new File("config", "divinemc-global.yml")) + .describedAs("Yml file"); + // DivineMC end - Configuration + diff --git a/divinemc-server/paper-patches/features/0004-Implement-Secure-Seed.patch b/divinemc-server/paper-patches/features/0004-Implement-Secure-Seed.patch index 2caabea..cc5e8f6 100644 --- a/divinemc-server/paper-patches/features/0004-Implement-Secure-Seed.patch +++ b/divinemc-server/paper-patches/features/0004-Implement-Secure-Seed.patch @@ -25,10 +25,10 @@ index de8b9048c8395c05b8688bc9d984b8ad680f15b3..98bd60111797225f3be5e2a19e25d654 @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index f5072cf579af02bde4d2f822f4e4b7973f0b7a83..cdd2fa08a813c8cec11472e378a19ce0ab3157c8 100644 +index 384ffd0d306cf01ce58864e9d2fcf7def6afca0f..12cfe2abd84f7ba63d935f91ce907bf3f52832da 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1408,7 +1408,11 @@ public final class CraftServer implements Server { +@@ -1414,7 +1414,11 @@ public final class CraftServer implements Server { registryAccess = levelDataAndDimensions.dimensions().dimensionsRegistryAccess(); } else { LevelSettings levelSettings; diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java b/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java index c6c35bc..6426504 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java @@ -2,7 +2,6 @@ package org.bxteam.divinemc; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.MemoryConfiguration; import org.bxteam.divinemc.entity.pathfinding.PathfindTaskRejectPolicy; @@ -14,11 +13,9 @@ import org.simpleyaml.exceptions.InvalidConfigurationException; import java.io.File; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.List; -import java.util.logging.Level; @SuppressWarnings("unused") public class DivineConfig { @@ -32,6 +29,8 @@ public class DivineConfig { New builds: https://github.com/BX-Team/DivineMC/releases/latest"""; public static final Logger LOGGER = LogManager.getLogger(DivineConfig.class.getSimpleName()); + public static final int CONFIG_VERSION = 5; + private static File configFile; public static final YamlFile config = new YamlFile(); private static int updates = 0; @@ -66,53 +65,35 @@ public class DivineConfig { } } - getString("config.version", "5"); - getBoolean("config.verbose", false); + getInt("config.version", CONFIG_VERSION); config.options().header(HEADER); - config.options().copyDefaults(true); - readConfig(configFile, config, DivineConfig.class, null); + for (Method method : DivineConfig.class.getDeclaredMethods()) { + if (Modifier.isStatic(method.getModifiers()) && Modifier.isPrivate(method.getModifiers()) && method.getParameterCount() == 0 && method.getReturnType() == Void.TYPE && !method.getName().startsWith("lambda")) { + method.setAccessible(true); + try { + method.invoke(null); + } catch (Throwable t) { + LOGGER.warn("Failed to load configuration option from " + method.getName(), t); + } + } + } + + updates++; + + config.save(configFile); } - public static void readConfig(Class clazz, @Nullable Object instance) { - readConfig(configFile, config, clazz, instance); - } - - private static void readConfig(File configFile, YamlFile config, Class clazz, @Nullable Object instance) { - for (Method method : clazz.getDeclaredMethods()) { - if (!Modifier.isPrivate(method.getModifiers())) continue; - if (method.getParameterTypes().length != 0) continue; - if (method.getReturnType() != Void.TYPE) continue; - - try { - method.setAccessible(true); - method.invoke(instance); - } catch (InvocationTargetException ex) { - throw new RuntimeException(ex.getCause()); - } catch (Exception ex) { - Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex); - } - } - - try { - config.save(configFile); - } catch (IOException ex) { - Bukkit.getLogger().log(Level.SEVERE, "Could not save " + configFile, ex); - } - } - private static void setComment(String key, String... comment) { if (config.contains(key)) { config.setComment(key, String.join("\n", comment), CommentType.BLOCK); } } - private static void ensureDefault(String key, Object defaultValue, String... comment) { - if (!config.contains(key)) { - config.set(key, defaultValue); - if (comment.length > 0) config.setComment(key, String.join("\n", comment), CommentType.BLOCK); - } - } + private static void ensureDefault(String key, Object defaultValue, String... comment) { + if (!config.contains(key)) config.set(key, defaultValue); + if (comment.length > 0) config.setComment(key, String.join("\n", comment), CommentType.BLOCK); + } private static boolean getBoolean(String key, boolean defaultValue, String... comment) { return getBoolean(key, null, defaultValue, comment); diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/DivineWorldConfig.java b/divinemc-server/src/main/java/org/bxteam/divinemc/DivineWorldConfig.java index 5f1f59e..75a43da 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/DivineWorldConfig.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/DivineWorldConfig.java @@ -1,65 +1,120 @@ package org.bxteam.divinemc; +import com.google.common.base.Throwables; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.bukkit.World; import org.simpleyaml.configuration.file.YamlFile; +import org.simpleyaml.exceptions.InvalidConfigurationException; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.List; import java.util.Map; -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "DuplicatedCode"}) public class DivineWorldConfig { - private final YamlFile config; + private static final String HEADER = """ + This is the world configuration file for DivineMC. + Configuration options here apply to all worlds, unless you specify overrides inside + the world-specific config file inside each world folder. + + If you need help with the configuration or have any questions related to DivineMC, + join us in our Discord server. + + Discord: https://discord.gg/p7cxhw7E2M + Docs: https://bxteam.org/docs/divinemc + New builds: https://github.com/BX-Team/DivineMC/releases/latest"""; + + public static final Logger LOGGER = LogManager.getLogger(DivineWorldConfig.class.getSimpleName()); + public static final int CONFIG_VERSION = 5; + + private static final YamlFile config = new YamlFile(); private final String worldName; private final World.Environment environment; - public DivineWorldConfig(String worldName, World.Environment environment) { - this.config = DivineConfig.config; + public DivineWorldConfig(String worldName, World.Environment environment) throws IOException { this.worldName = worldName; this.environment = environment; init(); } - public void init() { - DivineConfig.readConfig(DivineWorldConfig.class, this); + public void init() throws IOException { + File configFile = new File("config", "divinemc-world.yml"); + + if (configFile.exists()) { + try { + config.load(configFile); + } catch (InvalidConfigurationException e) { + throw new IOException(e); + } + } + + config.getInt("config.version", CONFIG_VERSION); + config.options().header(HEADER); + + for (Method method : DivineWorldConfig.class.getDeclaredMethods()) { + if (Modifier.isPrivate(method.getModifiers())) { + if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) { + try { + method.setAccessible(true); + method.invoke(this); + } catch (InvocationTargetException ex) { + throw Throwables.propagate(ex.getCause()); + } catch (Exception ex) { + LOGGER.error("Error invoking {}", method.getName(), ex); + } + } + } + } + + try { + config.save(configFile); + } catch (IOException ex) { + LOGGER.error("Could not save {}", configFile, ex); + } } private void set(String path, Object val) { - this.config.addDefault("settings.world-settings.default." + path, val); - this.config.set("settings.world-settings.default." + path, val); - if (this.config.get("settings.world-settings." + worldName + "." + path) != null) { - this.config.addDefault("settings.world-settings." + worldName + "." + path, val); - this.config.set("settings.world-settings." + worldName + "." + path, val); + config.addDefault("world-settings.default." + path, val); + config.set("world-settings.default." + path, val); + if (config.get("world-settings." + worldName + "." + path) != null) { + config.addDefault("world-settings." + worldName + "." + path, val); + config.set("world-settings." + worldName + "." + path, val); } } private String getString(String path, String def) { - this.config.addDefault("settings.world-settings.default." + path, def); - return this.config.getString("settings.world-settings." + worldName + "." + path, this.config.getString("settings.world-settings.default." + path)); + config.addDefault("world-settings.default." + path, def); + return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path)); } private boolean getBoolean(String path, boolean def) { - this.config.addDefault("settings.world.default." + path, def); - return this.config.getBoolean("settings.world-settings." + worldName + "." + path, this.config.getBoolean("settings.world-settings.default." + path)); + config.addDefault("settings.world.default." + path, def); + return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path)); } private double getDouble(String path, double def) { - this.config.addDefault("settings.world-settings.default." + path, def); - return this.config.getDouble("settings.world-settings." + worldName + "." + path, this.config.getDouble("settings.world-settings.default." + path)); + config.addDefault("world-settings.default." + path, def); + return config.getDouble("world-settings." + worldName + "." + path, config.getDouble("world-settings.default." + path)); } private int getInt(String path, int def) { - this.config.addDefault("settings.world-settings.default." + path, def); - return this.config.getInt("settings.world-settings." + worldName + "." + path, this.config.getInt("settings.world-settings.default." + path)); + config.addDefault("world-settings.default." + path, def); + return config.getInt("world-settings." + worldName + "." + path, config.getInt("world-settings.default." + path)); } private List getList(String path, T def) { - this.config.addDefault("settings.world-settings.default." + path, def); - return this.config.getList("settings.world-settings." + worldName + "." + path, this.config.getList("settings.world-settings.default." + path)); + config.addDefault("world-settings.default." + path, def); + return config.getList("world-settings." + worldName + "." + path, config.getList("world-settings.default." + path)); } private Map getMap(String path, Map def) { - final Map fallback = this.getMap("settings.world-settings.default." + path, def); - final Map value = this.getMap("settings.world-settings." + worldName + "." + path, null); + final Map fallback = this.getMap("world-settings.default." + path, def); + final Map value = this.getMap("world-settings." + worldName + "." + path, null); return value.isEmpty() ? fallback : value; } diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/command/subcommands/ReloadCommand.java b/divinemc-server/src/main/java/org/bxteam/divinemc/command/subcommands/ReloadCommand.java index f4bc27b..398b29c 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/command/subcommands/ReloadCommand.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/command/subcommands/ReloadCommand.java @@ -44,7 +44,11 @@ public final class ReloadCommand extends DivineSubCommandPermission { } for (ServerLevel level : server.getAllLevels()) { - level.divineConfig.init(); + try { + level.divineConfig.init(); + } catch (IOException e) { + MinecraftServer.LOGGER.error("Failed to reload DivineMC world config for level " + level.dimension().location(), e); + } level.resetBreedingCooldowns(); } server.server.reloadCount++;