Add support for hiding individual subzones on Residence

This commit is contained in:
Mike Primm 2011-10-22 18:38:50 -05:00
parent f4a8f3ab03
commit bd0ddb160b
3 changed files with 55 additions and 59 deletions

View File

@ -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<String> idlist = regions.getStrings("visibleregions", null);
List<String> hidlist = regions.getStrings("hiddenregions", null);
if((idlist != null) || (hidlist != null)) {
@SuppressWarnings("unchecked")
HashSet<String> ids = new HashSet<String>((Collection<? extends String>) 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());

View File

@ -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<String> idlist = configuration.getStrings("visibleregions", null);
List<String> hidlist = configuration.getStrings("hiddenregions", null);
if((regionData != null) && ((idlist != null) || (hidlist != null))) {
@SuppressWarnings("unchecked")
HashSet<String> ids = new HashSet<String>((Collection<? extends String>) 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<String> idlist, List<String> 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<String> ids = new HashSet<String>((Collection<? extends String>) 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);
}
}
}
}
}
}
}
}
}
}

View File

@ -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