From 3767b0d9bade64b96c5840b6ca730ceefe3ebc93 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sun, 23 Oct 2011 07:38:50 +0800 Subject: [PATCH] Add support for hiding individual subzones on Residence --- .../org/dynmap/regions/RegionHandler.java | 31 +------ .../org/dynmap/regions/RegionsComponent.java | 80 ++++++++++++------- src/main/resources/configuration.txt | 3 +- 3 files changed, 55 insertions(+), 59 deletions(-) diff --git a/src/main/java/org/dynmap/regions/RegionHandler.java b/src/main/java/org/dynmap/regions/RegionHandler.java index 00d830f5..63fe8122 100644 --- a/src/main/java/org/dynmap/regions/RegionHandler.java +++ b/src/main/java/org/dynmap/regions/RegionHandler.java @@ -8,6 +8,7 @@ import java.io.InputStream; import java.util.Collection; import java.util.Map; import java.util.HashSet; +import java.util.Set; import java.util.logging.Level; import org.bukkit.util.config.Configuration; import org.dynmap.ConfigurationNode; @@ -108,34 +109,8 @@ 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); - 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 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); - } - } - } - } + RegionsComponent.filterOutHidden(regions.getStrings("visibleregions", null), regions.getStrings("hiddenregions", null), regionData, regiontype); + try { ByteArrayOutputStream fos = new ByteArrayOutputStream(); fos.write(Json.stringifyJson(regionData).getBytes()); diff --git a/src/main/java/org/dynmap/regions/RegionsComponent.java b/src/main/java/org/dynmap/regions/RegionsComponent.java index 8de64edf..5f5b4754 100644 --- a/src/main/java/org/dynmap/regions/RegionsComponent.java +++ b/src/main/java/org/dynmap/regions/RegionsComponent.java @@ -8,6 +8,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.bukkit.World; import org.dynmap.ClientComponent; @@ -122,36 +123,9 @@ public class RegionsComponent extends ClientComponent { outputFileName = outputFileName.substring(0, outputFileName.lastIndexOf("."))+".json"; webWorldPath = new File(plugin.getWebPath()+"/standalone/", outputFileName); } - /* See if we have explicit list of regions to report - limit to this list if we do */ - List idlist = configuration.getStrings("visibleregions", null); - List hidlist = configuration.getStrings("hiddenregions", null); - if((regionData != null) && ((idlist != null) || (hidlist != null))) { - @SuppressWarnings("unchecked") - HashSet ids = new HashSet((Collection) regionData.keySet()); - for(String id : ids) { - /* 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); - } - } - } - } - + /* Process out hidden data */ + filterOutHidden(configuration.getStrings("visibleregions", null), configuration.getStrings("hiddenregions", null), regionData, regiontype); + if (webWorldPath.isAbsolute()) outputFile = webWorldPath; else { @@ -175,4 +149,50 @@ public class RegionsComponent extends ClientComponent { } } + public static void filterOutHidden(List idlist, List hidlist, Map regionData, String regiontype) { + /* See if we have explicit list of regions to report - limit to this list if we do */ + if((regionData != null) && ((idlist != null) || (hidlist != null))) { + @SuppressWarnings("unchecked") + HashSet ids = new HashSet((Collection) regionData.keySet()); + for(String id : ids) { + /* 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) { + if(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); + } + } + if(regiontype.equals("Residence")) { + Map m = (Map)regionData.get(id); + if(m != null) { + m = (Map)m.get("Subzones"); + if(m != null) { + Set ks = m.keySet(); + for(Object k : ks) { + String sid = id + "." + k; + if(hidlist.contains(sid)) { + m.remove(k); + } + } + } + } + } + } + } + } + } } diff --git a/src/main/resources/configuration.txt b/src/main/resources/configuration.txt index 1f445c53..83966e73 100644 --- a/src/main/resources/configuration.txt +++ b/src/main/resources/configuration.txt @@ -151,6 +151,7 @@ components: # visibleregions: # - homebase # - miningsite + # - area.subzone1 # # Optional setting to hide specific regions, by name # hiddenregions: # - hiddenplace @@ -316,7 +317,7 @@ maxchunkspertick: 200 # Progress report interval for fullrender/radiusrender, in tiles. Must be 100 or greater progressloginterval: 100 -# EXPERIMENTAL - parallel fullrender: if defined, number of concurrent threads used for fullrender or radiusrender +# Parallel fullrender: if defined, number of concurrent threads used for fullrender or radiusrender # Note: setting this will result in much more intensive CPU use, some additional memory use. Caution should be used when # setting this to equal or exceed the number of physical cores on the system. #parallelrendercnt: 4