diff --git a/.gitignore b/.gitignore index 408c231..eb0e1a5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ # netbeans /nbproject +# IntelliJ IDEA +/.idea/ + # we use maven! /build.xml @@ -22,4 +25,4 @@ /manifest.mf # Mac filesystem dust -/.DS_Store \ No newline at end of file +/.DS_Store diff --git a/src/main/java/org/dynmap/worldguard/DynmapWorldGuardPlugin.java b/src/main/java/org/dynmap/worldguard/DynmapWorldGuardPlugin.java index 74d9aad..9f65f71 100644 --- a/src/main/java/org/dynmap/worldguard/DynmapWorldGuardPlugin.java +++ b/src/main/java/org/dynmap/worldguard/DynmapWorldGuardPlugin.java @@ -11,6 +11,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import com.sk89q.worldguard.protection.flags.registry.FlagConflictException; import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; @@ -43,14 +44,18 @@ import com.sk89q.worldguard.protection.regions.RegionContainer; import com.sk89q.worldguard.protection.regions.RegionType; +import javax.annotation.Nullable; + public class DynmapWorldGuardPlugin extends JavaPlugin { private static Logger log; private static final String DEF_INFOWINDOW = "
%regionname%
Owner %playerowners%
Flags
%flags%
"; public static final String BOOST_FLAG = "dynmap-boost"; + public static final String VISIBLE_FLAG = "dynmap-showonmap"; Plugin dynmap; DynmapAPI api; MarkerAPI markerapi; BooleanFlag boost_flag; + BooleanFlag visible_flag; int updatesPerTick = 20; FileConfiguration cfg; @@ -66,6 +71,8 @@ public class DynmapWorldGuardPlugin extends JavaPlugin { Set hidden; boolean stop; int maxdepth; + boolean vbfEnabled; + boolean vbfHideByDefault; @Override public void onLoad() { @@ -146,7 +153,32 @@ private boolean isVisible(String id, String worldname) { } return true; } - + + private boolean isVisible( + final @Nullable ProtectedRegion region, + final @Nullable World world + ) { + if (region == null || world == null) { + return false; + } + + if (!(this.isVisible(region.getId(), world.getName()))) { + return false; + } + + if (vbfEnabled) { + Boolean visibleFlag = region.getFlag(visible_flag); + + if (visibleFlag == null) { + return !vbfHideByDefault; + } + + return visibleFlag; + } + + return true; + } + private void addStyle(String resid, String worldid, AreaMarker m, ProtectedRegion region) { AreaStyle as = cusstyle.get(worldid + "/" + resid); if(as == null) { @@ -237,7 +269,7 @@ private void handleRegion(World world, ProtectedRegion region, Map