Skip to content

Commit 2c6d1b2

Browse files
committed
Add support for WG Custom Flag, dynmap-boost, for setting resolution boost for regions
1 parent fc6e3fe commit 2c6d1b2

File tree

5 files changed

+47
-8
lines changed

5 files changed

+47
-8
lines changed

WGCustomFlags-1.5.2.jar

76.2 KB
Binary file not shown.

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,12 @@
8181
<scope>system</scope>
8282
<systemPath>${project.basedir}/worldedit-5.5.6.jar</systemPath>
8383
</dependency>
84+
<dependency>
85+
<groupId>com.sk89q</groupId>
86+
<artifactId>WGCustomFlags</artifactId>
87+
<version>1.5.2</version>
88+
<scope>system</scope>
89+
<systemPath>${project.basedir}/WGCustomFlags-1.5.2.jar</systemPath>
90+
</dependency>
8491
</dependencies>
8592
</project>

src/main/java/org/dynmap/worldguard/DynmapWorldGuardPlugin.java

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
import org.dynmap.markers.MarkerAPI;
2525
import org.dynmap.markers.MarkerSet;
2626

27+
import com.mewin.WGCustomFlags.WGCustomFlagsPlugin;
2728
import com.sk89q.worldedit.BlockVector;
2829
import com.sk89q.worldedit.BlockVector2D;
2930
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
3031
import com.sk89q.worldguard.domains.DefaultDomain;
32+
import com.sk89q.worldguard.protection.flags.BooleanFlag;
3133
import com.sk89q.worldguard.protection.flags.Flag;
3234
import com.sk89q.worldguard.protection.managers.RegionManager;
3335
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
@@ -36,10 +38,12 @@
3638
public class DynmapWorldGuardPlugin extends JavaPlugin {
3739
private static Logger log;
3840
private static final String DEF_INFOWINDOW = "<div class=\"infowindow\"><span style=\"font-size:120%;\">%regionname%</span><br /> Owner <span style=\"font-weight:bold;\">%playerowners%</span><br />Flags<br /><span style=\"font-weight:bold;\">%flags%</span></div>";
41+
public static final String BOOST_FLAG = "dynmap-boost";
3942
Plugin dynmap;
4043
DynmapAPI api;
4144
MarkerAPI markerapi;
4245
WorldGuardPlugin wg;
46+
BooleanFlag boost_flag;
4347

4448
FileConfiguration cfg;
4549
MarkerSet set;
@@ -68,7 +72,6 @@ private static class AreaStyle {
6872
String fillcolor;
6973
double fillopacity;
7074
String label;
71-
boolean boost;
7275

7376
AreaStyle(FileConfiguration cfg, String path, AreaStyle def) {
7477
strokecolor = cfg.getString(path+".strokeColor", def.strokecolor);
@@ -78,7 +81,6 @@ private static class AreaStyle {
7881
fillcolor = cfg.getString(path+".fillColor", def.fillcolor);
7982
fillopacity = cfg.getDouble(path+".fillOpacity", def.fillopacity);
8083
label = cfg.getString(path+".label", null);
81-
boost = cfg.getBoolean(path+".boost", def.boost);
8284
}
8385

8486
AreaStyle(FileConfiguration cfg, String path) {
@@ -88,7 +90,6 @@ private static class AreaStyle {
8890
strokeweight = cfg.getInt(path+".strokeWeight", 3);
8991
fillcolor = cfg.getString(path+".fillColor", "#FF0000");
9092
fillopacity = cfg.getDouble(path+".fillOpacity", 0.35);
91-
boost = cfg.getBoolean(path+".boost", false);
9293
}
9394
}
9495

@@ -200,7 +201,10 @@ else if((tok.length >= 2) && resid.startsWith(tok[0]) && resid.endsWith(tok[1]))
200201
if(as.label != null) {
201202
m.setLabel(as.label);
202203
}
203-
m.setBoostFlag(as.boost);
204+
if (boost_flag != null) {
205+
Boolean b = region.getFlag(boost_flag);
206+
m.setBoostFlag((b == null)?false:b.booleanValue());
207+
}
204208
}
205209

206210
/* Handle specific region */
@@ -330,6 +334,8 @@ public void onEnable() {
330334
wg = (WorldGuardPlugin)p;
331335

332336
getServer().getPluginManager().registerEvents(new OurServerListener(), this);
337+
338+
registerCustomFlags();
333339
/* If both enabled, activate */
334340
if(dynmap.isEnabled() && wg.isEnabled())
335341
activate();
@@ -342,9 +348,36 @@ public void onEnable() {
342348
}
343349
}
344350

351+
private WGCustomFlagsPlugin getWGCustomFlags()
352+
{
353+
Plugin plugin = getServer().getPluginManager().getPlugin("WGCustomFlags");
354+
355+
if (plugin == null || !(plugin instanceof WGCustomFlagsPlugin))
356+
{
357+
return null;
358+
}
359+
360+
return (WGCustomFlagsPlugin) plugin;
361+
}
362+
363+
private void registerCustomFlags() {
364+
try {
365+
WGCustomFlagsPlugin cf = getWGCustomFlags();
366+
if (cf != null) {
367+
BooleanFlag bf = new BooleanFlag(BOOST_FLAG);
368+
cf.addCustomFlag(bf);
369+
boost_flag = bf;
370+
}
371+
} catch (Exception x) {
372+
}
373+
if (boost_flag == null) {
374+
log.info("Custom flag '" + BOOST_FLAG + "' not registered - WGCustomFlags not found");
375+
}
376+
}
377+
345378
private boolean reload = false;
346379

347-
private void activate() {
380+
private void activate() {
348381
/* Now, get markers API */
349382
markerapi = api.getMarkerAPI();
350383
if(markerapi == null) {

src/main/resources/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ regionstyle:
2626
fillColor: "#FF0000"
2727
fillOpacity: 0.35
2828
unownedStrokeColor: "#00FF00"
29-
boost: false
3029

3130
# Optional setting to limit which regions to show, by name - if commented out, all regions are shown
3231
# To show all regions on a given world, add 'world:<worldname>' to the list
@@ -41,7 +40,6 @@ hiddenregions: [ ]
4140
custstyle:
4241
customregion1:
4342
strokeColor: "#00FF00"
44-
boost: true
4543

4644
# Optional per-owner overrides for regionstyle (lower priority than custstyle) - works for group or user names
4745
ownerstyle:

src/main/resources/plugin.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ name: Dynmap-WorldGuard
22
main: org.dynmap.worldguard.DynmapWorldGuardPlugin
33
version: "${project.version}"
44
author: mikeprimm
5-
depend: [ dynmap, WorldGuard ]
5+
depend: [ dynmap, WorldGuard ]
6+
softdepend: [ WGCustomFlags ]
67

0 commit comments

Comments
 (0)