diff --git a/configuration.txt b/configuration.txt index 025710df..5401e0a1 100644 --- a/configuration.txt +++ b/configuration.txt @@ -60,6 +60,10 @@ components: # strokeWeight: 3 # fillColor: "#FF0000" # fillOpacity: 0.35 + # # Optional setting to limit which regions to show, by name - if commented out, all regions are shown + # visibleregions: + # - homebase + # - miningsite #- class: org.dynmap.TestComponent # stuff: "This is some configuration-value" diff --git a/src/main/java/org/dynmap/regions/RegionHandler.java b/src/main/java/org/dynmap/regions/RegionHandler.java index a8bc8f64..48aa9616 100644 --- a/src/main/java/org/dynmap/regions/RegionHandler.java +++ b/src/main/java/org/dynmap/regions/RegionHandler.java @@ -1,10 +1,13 @@ package org.dynmap.regions; import java.io.File; +import java.util.List; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.util.Collection; import java.util.Map; +import java.util.HashSet; import java.util.logging.Level; import org.bukkit.util.config.Configuration; import org.dynmap.ConfigurationNode; @@ -60,6 +63,21 @@ public class RegionHandler extends FileHandler { regionConfig.load(); /* Parse region data and store in MemoryInputStream */ Map regionData = (Map) regionConfig.getProperty(regions.getString("basenode", "regions")); + /* 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) { + @SuppressWarnings("unchecked") + HashSet ids = new HashSet((Collection) regionData.keySet()); + for(String id : ids) { + /* If not in list, remove it */ + if(!idlist.contains(id)) { + regionData.remove(id); + log.info("discard " + id); + } + else + log.info("keep " + id); + } + } try { ByteArrayOutputStream fos = new ByteArrayOutputStream(); fos.write(Json.stringifyJson(regionData).getBytes());