mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-01 06:33:38 +01:00
Add support in regions component for 'hiddenregions' (blacklist for regions)
This commit is contained in:
parent
82b0f2c4cd
commit
8e22e40c16
@ -41,7 +41,8 @@ public class RegionHandler extends FileHandler {
|
|||||||
/* If using worldpath, format is either plugins/<plugin>/<worldname>/<filename> OR
|
/* If using worldpath, format is either plugins/<plugin>/<worldname>/<filename> OR
|
||||||
* plugins/<plugin>/worlds/<worldname>/<filename>
|
* 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)
|
if(basepath.exists() == false)
|
||||||
return null;
|
return null;
|
||||||
if(regions.getBoolean("useworldpath", false)) {
|
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 */
|
/* 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> idlist = regions.getStrings("visibleregions", null);
|
||||||
if(idlist != null) {
|
List<String> hidlist = regions.getStrings("hiddenregions", null);
|
||||||
|
if((idlist != null) || (hidlist != null)) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
HashSet<String> ids = new HashSet<String>((Collection<? extends String>) regionData.keySet());
|
HashSet<String> ids = new HashSet<String>((Collection<? extends String>) regionData.keySet());
|
||||||
for(String id : ids) {
|
for(String id : ids) {
|
||||||
/* If not in list, remove it */
|
/* If include list defined, and we're not in it, remove */
|
||||||
if(!idlist.contains(id)) {
|
if((idlist != null) && (!idlist.contains(id))) {
|
||||||
regionData.remove(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 {
|
||||||
|
@ -53,15 +53,16 @@ public class RegionsComponent extends ClientComponent {
|
|||||||
{
|
{
|
||||||
File outputFile;
|
File outputFile;
|
||||||
org.bukkit.util.config.Configuration regionConfig = null;
|
org.bukkit.util.config.Configuration regionConfig = null;
|
||||||
|
String regiontype = configuration.getString("name", "WorldGuard");
|
||||||
if(configuration.getBoolean("useworldpath", false))
|
if(configuration.getBoolean("useworldpath", false))
|
||||||
{
|
{
|
||||||
if(new File("plugins/"+configuration.getString("name", "WorldGuard"), regionFile).exists())
|
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));
|
regionConfig = new org.bukkit.util.config.Configuration(new File("plugins/"+regiontype, regionFile));
|
||||||
else if(new File("plugins/"+configuration.getString("name", "WorldGuard")+"/worlds", regionFile).exists())
|
else if(new File("plugins/"+regiontype+"/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+"/worlds", regionFile));
|
||||||
}
|
}
|
||||||
else
|
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
|
//File didn't exist
|
||||||
if(regionConfig == null)
|
if(regionConfig == null)
|
||||||
return;
|
return;
|
||||||
@ -73,14 +74,31 @@ public class RegionsComponent extends ClientComponent {
|
|||||||
Map<?, ?> regionData = (Map<?, ?>) regionConfig.getProperty(configuration.getString("basenode", "regions"));
|
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 */
|
/* 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> idlist = configuration.getStrings("visibleregions", null);
|
||||||
if(idlist != null) {
|
List<String> hidlist = configuration.getStrings("hiddenregions", null);
|
||||||
|
if((idlist != null) || (hidlist != null)) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
HashSet<String> ids = new HashSet<String>((Collection<? extends String>) regionData.keySet());
|
HashSet<String> ids = new HashSet<String>((Collection<? extends String>) regionData.keySet());
|
||||||
for(String id : ids) {
|
for(String id : ids) {
|
||||||
/* If not in list, remove it */
|
/* If include list defined, and we're not in it, remove */
|
||||||
if(!idlist.contains(id)) {
|
if((idlist != null) && (!idlist.contains(id))) {
|
||||||
regionData.remove(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:
|
# visibleregions:
|
||||||
# - homebase
|
# - homebase
|
||||||
# - miningsite
|
# - miningsite
|
||||||
|
# # Optional setting to hide specific regions, by name
|
||||||
|
# hiddenregions:
|
||||||
|
# - hiddenplace
|
||||||
|
# - secretsite
|
||||||
#- class: org.dynmap.regions.RegionsComponent
|
#- class: org.dynmap.regions.RegionsComponent
|
||||||
# type: regions
|
# type: regions
|
||||||
# name: Residence
|
# name: Residence
|
||||||
@ -102,6 +106,10 @@ components:
|
|||||||
# visibleregions:
|
# visibleregions:
|
||||||
# - homebase
|
# - homebase
|
||||||
# - miningsite
|
# - miningsite
|
||||||
|
# # Optional setting to hide specific regions, by name
|
||||||
|
# hiddenregions:
|
||||||
|
# - hiddenplace
|
||||||
|
# - secretsite
|
||||||
#- class: org.dynmap.TestComponent
|
#- class: org.dynmap.TestComponent
|
||||||
# stuff: "This is some configuration-value"
|
# stuff: "This is some configuration-value"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user