diff --git a/src/main/java/org/dynmap/regions/RegionHandler.java b/src/main/java/org/dynmap/regions/RegionHandler.java index 0875afcf..a1bc373c 100644 --- a/src/main/java/org/dynmap/regions/RegionHandler.java +++ b/src/main/java/org/dynmap/regions/RegionHandler.java @@ -41,7 +41,8 @@ public class RegionHandler extends FileHandler { /* If using worldpath, format is either plugins/// OR * plugins//worlds// */ - File basepath = new File("plugins", regions.getString("name", "WorldGuard")); + String regiontype = regions.getString("name", "WorldGuard"); + File basepath = new File("plugins", regiontype); if(basepath.exists() == false) return null; if(regions.getBoolean("useworldpath", false)) { @@ -71,14 +72,31 @@ public class RegionHandler extends FileHandler { } /* See if we have explicit list of regions to report - limit to this list if we do */ List idlist = regions.getStrings("visibleregions", null); - if(idlist != null) { + List hidlist = regions.getStrings("hiddenregions", null); + if((idlist != null) || (hidlist != null)) { @SuppressWarnings("unchecked") HashSet ids = new HashSet((Collection) regionData.keySet()); for(String id : ids) { - /* If not in list, remove it */ - if(!idlist.contains(id)) { + /* If include list defined, and we're not in it, remove */ + if((idlist != null) && (!idlist.contains(id))) { regionData.remove(id); } + /* If exclude list defined, and we're on it, remove */ + else if((hidlist != null) && (hidlist.contains(id))) { + /* If residence, we want to zap the areas list, so that we still get subregions */ + if(regiontype.equals("Residence")) { + Map m = (Map)regionData.get(id); + if(m != null) { + Map a = (Map)m.get("Areas"); + if(a != null) { + a.clear(); + } + } + } + else { + regionData.remove(id); + } + } } } try { diff --git a/src/main/java/org/dynmap/regions/RegionsComponent.java b/src/main/java/org/dynmap/regions/RegionsComponent.java index 770d37e4..278c6408 100644 --- a/src/main/java/org/dynmap/regions/RegionsComponent.java +++ b/src/main/java/org/dynmap/regions/RegionsComponent.java @@ -53,15 +53,16 @@ public class RegionsComponent extends ClientComponent { { File outputFile; org.bukkit.util.config.Configuration regionConfig = null; + String regiontype = configuration.getString("name", "WorldGuard"); if(configuration.getBoolean("useworldpath", false)) { if(new File("plugins/"+configuration.getString("name", "WorldGuard"), regionFile).exists()) - regionConfig = new org.bukkit.util.config.Configuration(new File("plugins/"+configuration.getString("name", "WorldGuard"), regionFile)); - else if(new File("plugins/"+configuration.getString("name", "WorldGuard")+"/worlds", regionFile).exists()) - regionConfig = new org.bukkit.util.config.Configuration(new File("plugins/"+configuration.getString("name", "WorldGuard")+"/worlds", regionFile)); + 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)); } else - regionConfig = new org.bukkit.util.config.Configuration(new File("plugins/"+configuration.getString("name", "WorldGuard"), regionFile)); + regionConfig = new org.bukkit.util.config.Configuration(new File("plugins/"+regiontype, regionFile)); //File didn't exist if(regionConfig == null) return; @@ -73,14 +74,31 @@ public class RegionsComponent extends ClientComponent { Map regionData = (Map) regionConfig.getProperty(configuration.getString("basenode", "regions")); /* See if we have explicit list of regions to report - limit to this list if we do */ List idlist = configuration.getStrings("visibleregions", null); - if(idlist != null) { + List hidlist = configuration.getStrings("hiddenregions", null); + if((idlist != null) || (hidlist != null)) { @SuppressWarnings("unchecked") HashSet ids = new HashSet((Collection) regionData.keySet()); for(String id : ids) { - /* If not in list, remove it */ - if(!idlist.contains(id)) { + /* If include list defined, and we're not in it, remove */ + if((idlist != null) && (!idlist.contains(id))) { regionData.remove(id); } + /* If exclude list defined, and we're on it, remove */ + else if((hidlist != null) && (hidlist.contains(id))) { + /* If residence, we want to zap the areas list, so that we still get subregions */ + if(regiontype.equals("Residence")) { + Map m = (Map)regionData.get(id); + if(m != null) { + Map a = (Map)m.get("Areas"); + if(a != null) { + a.clear(); + } + } + } + else { + regionData.remove(id); + } + } } } diff --git a/src/main/resources/configuration.txt b/src/main/resources/configuration.txt index 588b1801..a9d56c6e 100644 --- a/src/main/resources/configuration.txt +++ b/src/main/resources/configuration.txt @@ -84,6 +84,10 @@ components: # visibleregions: # - homebase # - miningsite + # # Optional setting to hide specific regions, by name + # hiddenregions: + # - hiddenplace + # - secretsite #- class: org.dynmap.regions.RegionsComponent # type: regions # name: Residence @@ -102,6 +106,10 @@ components: # visibleregions: # - homebase # - miningsite + # # Optional setting to hide specific regions, by name + # hiddenregions: + # - hiddenplace + # - secretsite #- class: org.dynmap.TestComponent # stuff: "This is some configuration-value"