No WorldConfig without ConfigurationSection; resolves #1052
This commit is contained in:
parent
81f520aabf
commit
2edf67b02c
|
@ -23,7 +23,6 @@ import de.erethon.dungeonsxl.world.WorldConfig;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a dungeon script. See {@link de.erethon.dungeonsxl.dungeon.DDungeon}.
|
* Represents a dungeon script. See {@link de.erethon.dungeonsxl.dungeon.DDungeon}.
|
||||||
|
@ -128,18 +127,8 @@ public class DungeonConfig extends DREConfig {
|
||||||
floorCount = config.getInt("floorCount", floors.size() + 2);
|
floorCount = config.getInt("floorCount", floors.size() + 2);
|
||||||
removeWhenPlayed = config.getBoolean("removeWhenPlayed", removeWhenPlayed);
|
removeWhenPlayed = config.getBoolean("removeWhenPlayed", removeWhenPlayed);
|
||||||
|
|
||||||
ConfigurationSection overrideSection = config.getConfigurationSection("overrideValues");
|
overrideValues = new WorldConfig(plugin, config.getConfigurationSection("overrideValues"));
|
||||||
if (overrideSection != null) {
|
defaultValues = new WorldConfig(plugin, config.getConfigurationSection("defaultValues"));
|
||||||
overrideValues = new WorldConfig(plugin, overrideSection);
|
|
||||||
} else {
|
|
||||||
overrideValues = new WorldConfig(plugin);
|
|
||||||
}
|
|
||||||
ConfigurationSection defaultSection = config.getConfigurationSection("defaultValues");
|
|
||||||
if (defaultValues != null) {
|
|
||||||
defaultValues = new WorldConfig(plugin, defaultSection);
|
|
||||||
} else {
|
|
||||||
defaultValues = new WorldConfig(plugin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -133,11 +133,7 @@ public class DResourceWorld implements ResourceWorld {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInvitedPlayer(OfflinePlayer player) {
|
public void addInvitedPlayer(OfflinePlayer player) {
|
||||||
if (config == null) {
|
getConfig(true).addInvitedPlayer(player.getUniqueId().toString());
|
||||||
config = new WorldConfig(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
config.addInvitedPlayer(player.getUniqueId().toString());
|
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,21 +47,18 @@ public class WorldConfig extends GameRuleContainer {
|
||||||
private List<String> invitedPlayers = new ArrayList<>();
|
private List<String> invitedPlayers = new ArrayList<>();
|
||||||
private Environment worldEnvironment;
|
private Environment worldEnvironment;
|
||||||
|
|
||||||
public WorldConfig(DungeonsXL plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorldConfig(DungeonsXL plugin, File file) {
|
public WorldConfig(DungeonsXL plugin, File file) {
|
||||||
this(plugin);
|
this.plugin = plugin;
|
||||||
|
|
||||||
this.file = file;
|
this.file = file;
|
||||||
config = YamlConfiguration.loadConfiguration(file);
|
config = YamlConfiguration.loadConfiguration(file);
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldConfig(DungeonsXL plugin, ConfigurationSection config) {
|
public WorldConfig(DungeonsXL plugin, ConfigurationSection config) {
|
||||||
this(plugin);
|
this.plugin = plugin;
|
||||||
|
if (config == null) {
|
||||||
|
config = new YamlConfiguration();
|
||||||
|
}
|
||||||
this.config = config;
|
this.config = config;
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue