mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-07-01 09:05:05 +02:00
Add support for hiding individual subzones on Residence
This commit is contained in:
parent
f4a8f3ab03
commit
bd0ddb160b
|
@ -8,6 +8,7 @@ import java.io.InputStream;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
import org.dynmap.ConfigurationNode;
|
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 */
|
/* See if we have explicit list of regions to report - limit to this list if we do */
|
||||||
List<String> idlist = regions.getStrings("visibleregions", null);
|
RegionsComponent.filterOutHidden(regions.getStrings("visibleregions", null), regions.getStrings("hiddenregions", null), regionData, regiontype);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream fos = new ByteArrayOutputStream();
|
ByteArrayOutputStream fos = new ByteArrayOutputStream();
|
||||||
fos.write(Json.stringifyJson(regionData).getBytes());
|
fos.write(Json.stringifyJson(regionData).getBytes());
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.dynmap.ClientComponent;
|
import org.dynmap.ClientComponent;
|
||||||
|
@ -122,35 +123,8 @@ public class RegionsComponent extends ClientComponent {
|
||||||
outputFileName = outputFileName.substring(0, outputFileName.lastIndexOf("."))+".json";
|
outputFileName = outputFileName.substring(0, outputFileName.lastIndexOf("."))+".json";
|
||||||
webWorldPath = new File(plugin.getWebPath()+"/standalone/", outputFileName);
|
webWorldPath = new File(plugin.getWebPath()+"/standalone/", outputFileName);
|
||||||
}
|
}
|
||||||
/* See if we have explicit list of regions to report - limit to this list if we do */
|
/* Process out hidden data */
|
||||||
List<String> idlist = configuration.getStrings("visibleregions", null);
|
filterOutHidden(configuration.getStrings("visibleregions", null), configuration.getStrings("hiddenregions", null), regionData, regiontype);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (webWorldPath.isAbsolute())
|
if (webWorldPath.isAbsolute())
|
||||||
outputFile = webWorldPath;
|
outputFile = webWorldPath;
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,7 @@ components:
|
||||||
# visibleregions:
|
# visibleregions:
|
||||||
# - homebase
|
# - homebase
|
||||||
# - miningsite
|
# - miningsite
|
||||||
|
# - area.subzone1
|
||||||
# # Optional setting to hide specific regions, by name
|
# # Optional setting to hide specific regions, by name
|
||||||
# hiddenregions:
|
# hiddenregions:
|
||||||
# - hiddenplace
|
# - hiddenplace
|
||||||
|
@ -316,7 +317,7 @@ maxchunkspertick: 200
|
||||||
# Progress report interval for fullrender/radiusrender, in tiles. Must be 100 or greater
|
# Progress report interval for fullrender/radiusrender, in tiles. Must be 100 or greater
|
||||||
progressloginterval: 100
|
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
|
# 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.
|
# setting this to equal or exceed the number of physical cores on the system.
|
||||||
#parallelrendercnt: 4
|
#parallelrendercnt: 4
|
||||||
|
|
Loading…
Reference in New Issue
Block a user