24
24
import org .dynmap .markers .MarkerAPI ;
25
25
import org .dynmap .markers .MarkerSet ;
26
26
27
+ import com .mewin .WGCustomFlags .WGCustomFlagsPlugin ;
27
28
import com .sk89q .worldedit .BlockVector ;
28
29
import com .sk89q .worldedit .BlockVector2D ;
29
30
import com .sk89q .worldguard .bukkit .WorldGuardPlugin ;
30
31
import com .sk89q .worldguard .domains .DefaultDomain ;
32
+ import com .sk89q .worldguard .protection .flags .BooleanFlag ;
31
33
import com .sk89q .worldguard .protection .flags .Flag ;
32
34
import com .sk89q .worldguard .protection .managers .RegionManager ;
33
35
import com .sk89q .worldguard .protection .regions .ProtectedPolygonalRegion ;
36
38
public class DynmapWorldGuardPlugin extends JavaPlugin {
37
39
private static Logger log ;
38
40
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" ;
39
42
Plugin dynmap ;
40
43
DynmapAPI api ;
41
44
MarkerAPI markerapi ;
42
45
WorldGuardPlugin wg ;
46
+ BooleanFlag boost_flag ;
43
47
44
48
FileConfiguration cfg ;
45
49
MarkerSet set ;
@@ -68,7 +72,6 @@ private static class AreaStyle {
68
72
String fillcolor ;
69
73
double fillopacity ;
70
74
String label ;
71
- boolean boost ;
72
75
73
76
AreaStyle (FileConfiguration cfg , String path , AreaStyle def ) {
74
77
strokecolor = cfg .getString (path +".strokeColor" , def .strokecolor );
@@ -78,7 +81,6 @@ private static class AreaStyle {
78
81
fillcolor = cfg .getString (path +".fillColor" , def .fillcolor );
79
82
fillopacity = cfg .getDouble (path +".fillOpacity" , def .fillopacity );
80
83
label = cfg .getString (path +".label" , null );
81
- boost = cfg .getBoolean (path +".boost" , def .boost );
82
84
}
83
85
84
86
AreaStyle (FileConfiguration cfg , String path ) {
@@ -88,7 +90,6 @@ private static class AreaStyle {
88
90
strokeweight = cfg .getInt (path +".strokeWeight" , 3 );
89
91
fillcolor = cfg .getString (path +".fillColor" , "#FF0000" );
90
92
fillopacity = cfg .getDouble (path +".fillOpacity" , 0.35 );
91
- boost = cfg .getBoolean (path +".boost" , false );
92
93
}
93
94
}
94
95
@@ -200,7 +201,10 @@ else if((tok.length >= 2) && resid.startsWith(tok[0]) && resid.endsWith(tok[1]))
200
201
if (as .label != null ) {
201
202
m .setLabel (as .label );
202
203
}
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
+ }
204
208
}
205
209
206
210
/* Handle specific region */
@@ -330,6 +334,8 @@ public void onEnable() {
330
334
wg = (WorldGuardPlugin )p ;
331
335
332
336
getServer ().getPluginManager ().registerEvents (new OurServerListener (), this );
337
+
338
+ registerCustomFlags ();
333
339
/* If both enabled, activate */
334
340
if (dynmap .isEnabled () && wg .isEnabled ())
335
341
activate ();
@@ -342,9 +348,36 @@ public void onEnable() {
342
348
}
343
349
}
344
350
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
+
345
378
private boolean reload = false ;
346
379
347
- private void activate () {
380
+ private void activate () {
348
381
/* Now, get markers API */
349
382
markerapi = api .getMarkerAPI ();
350
383
if (markerapi == null ) {
0 commit comments