mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Use game rules from registry instead of default VALUES array
This commit is contained in:
parent
929a87ac68
commit
5d452db92d
@ -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<String, Dungeon> dungeonRegistry = new Registry<>();
|
||||
private Registry<String, ResourceWorld> mapRegistry = new Registry<>();
|
||||
private Registry<Integer, InstanceWorld> instanceCache = new Registry<>();
|
||||
private Registry<String, GameRule> gameRuleRegistry = new Registry<>();
|
||||
private Registry<String, GameRule> gameRuleRegistry = new GameRuleRegistry();
|
||||
private Registry<String, ExternalMobProvider> externalMobProviderRegistry = new Registry<>();
|
||||
private Registry<String, PlayerGroup> playerGroupCache = new Registry<>();
|
||||
|
||||
@ -149,6 +150,16 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
|
||||
|
||||
}
|
||||
|
||||
private class GameRuleRegistry extends Registry<String, GameRule> {
|
||||
|
||||
@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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user