mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +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.Dungeon;
|
||||||
import de.erethon.dungeonsxl.api.dungeon.Game;
|
import de.erethon.dungeonsxl.api.dungeon.Game;
|
||||||
import de.erethon.dungeonsxl.api.dungeon.GameRule;
|
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.DungeonMob;
|
||||||
import de.erethon.dungeonsxl.api.mob.ExternalMobProvider;
|
import de.erethon.dungeonsxl.api.mob.ExternalMobProvider;
|
||||||
import de.erethon.dungeonsxl.api.player.GroupAdapter;
|
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, Dungeon> dungeonRegistry = new Registry<>();
|
||||||
private Registry<String, ResourceWorld> mapRegistry = new Registry<>();
|
private Registry<String, ResourceWorld> mapRegistry = new Registry<>();
|
||||||
private Registry<Integer, InstanceWorld> instanceCache = 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, ExternalMobProvider> externalMobProviderRegistry = new Registry<>();
|
||||||
private Registry<String, PlayerGroup> playerGroupCache = 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 boolean loadingWorld;
|
||||||
|
|
||||||
private GlobalData globalData;
|
private GlobalData globalData;
|
||||||
@ -312,6 +323,10 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
|
|||||||
globalData = new GlobalData(this, new File(getDataFolder(), "data.yml"));
|
globalData = new GlobalData(this, new File(getDataFolder(), "data.yml"));
|
||||||
globalData.load();
|
globalData.load();
|
||||||
|
|
||||||
|
for (GameRule rule : GameRule.VALUES) {
|
||||||
|
gameRuleRegistry.add(rule.getKey(), rule);
|
||||||
|
}
|
||||||
|
|
||||||
// Mobs - Supported providers
|
// Mobs - Supported providers
|
||||||
for (ExternalMobPlugin externalMobPlugin : ExternalMobPlugin.values()) {
|
for (ExternalMobPlugin externalMobPlugin : ExternalMobPlugin.values()) {
|
||||||
externalMobProviderRegistry.add(externalMobPlugin.getIdentifier(), externalMobPlugin);
|
externalMobProviderRegistry.add(externalMobPlugin.getIdentifier(), externalMobPlugin);
|
||||||
|
@ -63,7 +63,7 @@ public class WorldConfig extends GameRuleContainer {
|
|||||||
|
|
||||||
// Load & Save
|
// Load & Save
|
||||||
public void load(ConfigurationSection config) {
|
public void load(ConfigurationSection config) {
|
||||||
for (GameRule rule : GameRule.VALUES) {
|
for (GameRule rule : plugin.getGameRuleRegistry()) {
|
||||||
rule.fromConfig(plugin, this, config);
|
rule.fromConfig(plugin, this, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user