diff --git a/WGCustomFlags-1.5.2.jar b/WGCustomFlags-1.5.2.jar new file mode 100644 index 0000000..3f7c9bb Binary files /dev/null and b/WGCustomFlags-1.5.2.jar differ diff --git a/pom.xml b/pom.xml index bed2860..9f76c61 100644 --- a/pom.xml +++ b/pom.xml @@ -81,5 +81,12 @@ system ${project.basedir}/worldedit-5.5.6.jar + + com.sk89q + WGCustomFlags + 1.5.2 + system + ${project.basedir}/WGCustomFlags-1.5.2.jar + \ No newline at end of file diff --git a/src/main/java/org/dynmap/worldguard/DynmapWorldGuardPlugin.java b/src/main/java/org/dynmap/worldguard/DynmapWorldGuardPlugin.java index 02fec70..3cd7228 100644 --- a/src/main/java/org/dynmap/worldguard/DynmapWorldGuardPlugin.java +++ b/src/main/java/org/dynmap/worldguard/DynmapWorldGuardPlugin.java @@ -24,10 +24,12 @@ import org.dynmap.markers.AreaMarker; import org.dynmap.markers.MarkerAPI; import org.dynmap.markers.MarkerSet; +import com.mewin.WGCustomFlags.WGCustomFlagsPlugin; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.domains.DefaultDomain; +import com.sk89q.worldguard.protection.flags.BooleanFlag; import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion; @@ -36,10 +38,12 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion; 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"; Plugin dynmap; DynmapAPI api; MarkerAPI markerapi; WorldGuardPlugin wg; + BooleanFlag boost_flag; FileConfiguration cfg; MarkerSet set; @@ -68,7 +72,6 @@ public class DynmapWorldGuardPlugin extends JavaPlugin { String fillcolor; double fillopacity; String label; - boolean boost; AreaStyle(FileConfiguration cfg, String path, AreaStyle def) { strokecolor = cfg.getString(path+".strokeColor", def.strokecolor); @@ -78,7 +81,6 @@ public class DynmapWorldGuardPlugin extends JavaPlugin { fillcolor = cfg.getString(path+".fillColor", def.fillcolor); fillopacity = cfg.getDouble(path+".fillOpacity", def.fillopacity); label = cfg.getString(path+".label", null); - boost = cfg.getBoolean(path+".boost", def.boost); } AreaStyle(FileConfiguration cfg, String path) { @@ -88,7 +90,6 @@ public class DynmapWorldGuardPlugin extends JavaPlugin { strokeweight = cfg.getInt(path+".strokeWeight", 3); fillcolor = cfg.getString(path+".fillColor", "#FF0000"); fillopacity = cfg.getDouble(path+".fillOpacity", 0.35); - boost = cfg.getBoolean(path+".boost", false); } } @@ -200,7 +201,10 @@ public class DynmapWorldGuardPlugin extends JavaPlugin { if(as.label != null) { m.setLabel(as.label); } - m.setBoostFlag(as.boost); + if (boost_flag != null) { + Boolean b = region.getFlag(boost_flag); + m.setBoostFlag((b == null)?false:b.booleanValue()); + } } /* Handle specific region */ @@ -330,6 +334,8 @@ public class DynmapWorldGuardPlugin extends JavaPlugin { wg = (WorldGuardPlugin)p; getServer().getPluginManager().registerEvents(new OurServerListener(), this); + + registerCustomFlags(); /* If both enabled, activate */ if(dynmap.isEnabled() && wg.isEnabled()) activate(); @@ -342,9 +348,36 @@ public class DynmapWorldGuardPlugin extends JavaPlugin { } } + private WGCustomFlagsPlugin getWGCustomFlags() + { + Plugin plugin = getServer().getPluginManager().getPlugin("WGCustomFlags"); + + if (plugin == null || !(plugin instanceof WGCustomFlagsPlugin)) + { + return null; + } + + return (WGCustomFlagsPlugin) plugin; + } + + private void registerCustomFlags() { + try { + WGCustomFlagsPlugin cf = getWGCustomFlags(); + if (cf != null) { + BooleanFlag bf = new BooleanFlag(BOOST_FLAG); + cf.addCustomFlag(bf); + boost_flag = bf; + } + } catch (Exception x) { + } + if (boost_flag == null) { + log.info("Custom flag '" + BOOST_FLAG + "' not registered - WGCustomFlags not found"); + } + } + private boolean reload = false; - private void activate() { + private void activate() { /* Now, get markers API */ markerapi = api.getMarkerAPI(); if(markerapi == null) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2aba386..34ce4f2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -26,7 +26,6 @@ regionstyle: fillColor: "#FF0000" fillOpacity: 0.35 unownedStrokeColor: "#00FF00" - boost: false # Optional setting to limit which regions to show, by name - if commented out, all regions are shown # To show all regions on a given world, add 'world:' to the list @@ -41,7 +40,6 @@ hiddenregions: [ ] custstyle: customregion1: strokeColor: "#00FF00" - boost: true # Optional per-owner overrides for regionstyle (lower priority than custstyle) - works for group or user names ownerstyle: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a5dddbe..2381be8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,5 +2,6 @@ name: Dynmap-WorldGuard main: org.dynmap.worldguard.DynmapWorldGuardPlugin version: "${project.version}" author: mikeprimm -depend: [ dynmap, WorldGuard ] +depend: [ dynmap, WorldGuard ] +softdepend: [ WGCustomFlags ]