Update support for new Residence configuration file layout

This commit is contained in:
Mike Primm 2011-09-29 08:07:39 +08:00 committed by mikeprimm
parent 7d79301293
commit dd4d448fc5
2 changed files with 38 additions and 2 deletions

View File

@ -55,6 +55,25 @@ public class RegionHandler extends FileHandler {
else if(regiontype.equals("Factions")) {
regionData = factions.getRegionData(worldname);
}
else if(regiontype.equals("Residence")) {
File f = new File("plugins/Residence/Save/Worlds", "res_" + worldname + ".yml");
if(f.exists()) {
regionConfig = new org.bukkit.util.config.Configuration(f);
}
else {
f = new File("plugins/Residence", "res.yml");
if(f.exists()) {
regionConfig = new org.bukkit.util.config.Configuration(f);
}
}
if(regionConfig == null) return null;
regionConfig.load();
regionData = (Map<?, ?>) regionConfig.getProperty("Residences");
if(regionData == null) {
Log.severe("Region data from " + f.getPath() + " does not include basenode 'Residences'");
return null;
}
}
else {
/* If using worldpath, format is either plugins/<plugin>/<worldname>/<filename> OR
* plugins/<plugin>/worlds/<worldname>/<filename>

View File

@ -73,7 +73,7 @@ public class RegionsComponent extends ClientComponent {
{
File outputFile;
org.bukkit.util.config.Configuration regionConfig = null;
Map<?, ?> regionData;
Map<?, ?> regionData = null;
File webWorldPath;
if(regiontype.equals("Towny")) {
@ -86,10 +86,27 @@ public class RegionsComponent extends ClientComponent {
outputFileName = "factions_" + wname + ".json";
webWorldPath = new File(plugin.getWebPath()+"/standalone/", outputFileName);
}
else if(regiontype.equals("Residence")) {
File f = new File("plugins/Residence/Save/Worlds", "res_" + wname + ".yml");
if(f.exists()) {
regionConfig = new org.bukkit.util.config.Configuration(f);
}
else {
f = new File("plugins/Residence", "res.yml");
if(f.exists()) {
regionConfig = new org.bukkit.util.config.Configuration(f);
}
}
if(regionConfig == null) return;
outputFileName = "res_" + wname + ".json";
webWorldPath = new File(plugin.getWebPath()+"/standalone/", outputFileName);
regionConfig.load();
regionData = (Map<?, ?>) regionConfig.getProperty("Residences");
}
else {
if(configuration.getBoolean("useworldpath", false))
{
if(new File("plugins/"+configuration.getString("name", "WorldGuard"), regionFile).exists())
if(new File("plugins/"+regiontype, regionFile).exists())
regionConfig = new org.bukkit.util.config.Configuration(new File("plugins/"+regiontype, regionFile));
else if(new File("plugins/"+regiontype+"/worlds", regionFile).exists())
regionConfig = new org.bukkit.util.config.Configuration(new File("plugins/"+regiontype+"/worlds", regionFile));