diff --git a/core/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java b/core/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java index 69b83f3b..9dcd18a5 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java +++ b/core/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java @@ -37,6 +37,7 @@ import de.erethon.dungeonsxl.api.Reward; import de.erethon.dungeonsxl.api.dungeon.Dungeon; import de.erethon.dungeonsxl.api.dungeon.Game; import de.erethon.dungeonsxl.api.dungeon.GameRule; +import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer; import de.erethon.dungeonsxl.api.mob.DungeonMob; import de.erethon.dungeonsxl.api.mob.ExternalMobProvider; import de.erethon.dungeonsxl.api.player.GroupAdapter; @@ -131,7 +132,7 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI { private Registry dungeonRegistry = new Registry<>(); private Registry mapRegistry = new Registry<>(); private Registry instanceCache = new Registry<>(); - private Registry gameRuleRegistry = new Registry<>(); + private Registry gameRuleRegistry = new GameRuleRegistry(); private Registry externalMobProviderRegistry = new Registry<>(); private Registry playerGroupCache = new Registry<>(); @@ -149,6 +150,16 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI { } + private class GameRuleRegistry extends Registry { + + @Override + public void add(String key, GameRule rule) { + super.add(key, rule); + GameRuleContainer.DEFAULT_VALUES.setState(rule, rule.getDefaultValue()); + } + + } + private boolean loadingWorld; private GlobalData globalData; @@ -312,6 +323,10 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI { globalData = new GlobalData(this, new File(getDataFolder(), "data.yml")); globalData.load(); + for (GameRule rule : GameRule.VALUES) { + gameRuleRegistry.add(rule.getKey(), rule); + } + // Mobs - Supported providers for (ExternalMobPlugin externalMobPlugin : ExternalMobPlugin.values()) { externalMobProviderRegistry.add(externalMobPlugin.getIdentifier(), externalMobPlugin); diff --git a/core/src/main/java/de/erethon/dungeonsxl/world/WorldConfig.java b/core/src/main/java/de/erethon/dungeonsxl/world/WorldConfig.java index 6b59f272..dfc2f6d2 100644 --- a/core/src/main/java/de/erethon/dungeonsxl/world/WorldConfig.java +++ b/core/src/main/java/de/erethon/dungeonsxl/world/WorldConfig.java @@ -63,7 +63,7 @@ public class WorldConfig extends GameRuleContainer { // Load & Save public void load(ConfigurationSection config) { - for (GameRule rule : GameRule.VALUES) { + for (GameRule rule : plugin.getGameRuleRegistry()) { rule.fromConfig(plugin, this, config); } }