mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-08-20 19:32:46 +02:00
Add support in regions component for 'hiddenregions' (blacklist for regions)
This commit is contained in:
parent
929ca8911e
commit
7e12574bd8
|
@ -41,7 +41,8 @@ public class RegionHandler extends FileHandler {
|
|||
/* If using worldpath, format is either plugins/<plugin>/<worldname>/<filename> OR
|
||||
* plugins/<plugin>/worlds/<worldname>/<filename>
|
||||
*/
|
||||
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<String> idlist = regions.getStrings("visibleregions", null);
|
||||
if(idlist != 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 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 {
|
||||
|
|
|
@ -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<String> idlist = configuration.getStrings("visibleregions", null);
|
||||
if(idlist != null) {
|
||||
List<String> hidlist = configuration.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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user