11
11
import java .util .logging .Level ;
12
12
import java .util .logging .Logger ;
13
13
14
- import org .bukkit .World ;
14
+ import org .bukkit .Bukkit ;
15
15
import org .bukkit .configuration .ConfigurationSection ;
16
16
import org .bukkit .configuration .file .FileConfiguration ;
17
17
import org .bukkit .event .EventHandler ;
26
26
import org .dynmap .markers .MarkerAPI ;
27
27
import org .dynmap .markers .MarkerSet ;
28
28
29
- import com .mewin .WGCustomFlags .WGCustomFlagsPlugin ;
30
29
import com .sk89q .worldedit .BlockVector ;
31
30
import com .sk89q .worldedit .BlockVector2D ;
31
+ import com .sk89q .worldedit .world .World ;
32
+ import com .sk89q .worldguard .WorldGuard ;
32
33
import com .sk89q .worldguard .bukkit .WorldGuardPlugin ;
33
34
import com .sk89q .worldguard .domains .DefaultDomain ;
34
35
import com .sk89q .worldguard .domains .PlayerDomain ;
36
+ import com .sk89q .worldguard .internal .platform .WorldGuardPlatform ;
35
37
import com .sk89q .worldguard .protection .flags .BooleanFlag ;
36
38
import com .sk89q .worldguard .protection .flags .Flag ;
39
+ import com .sk89q .worldguard .protection .flags .Flags ;
40
+ import com .sk89q .worldguard .protection .flags .registry .FlagRegistry ;
37
41
import com .sk89q .worldguard .protection .managers .RegionManager ;
38
42
import com .sk89q .worldguard .protection .regions .ProtectedPolygonalRegion ;
39
43
import com .sk89q .worldguard .protection .regions .ProtectedRegion ;
44
+ import com .sk89q .worldguard .protection .regions .RegionContainer ;
40
45
import com .sk89q .worldguard .protection .regions .RegionType ;
41
- import com .sk89q .worldguard .util .profile .Profile ;
42
- import com .sk89q .worldguard .util .profile .cache .ProfileCache ;
43
46
44
47
public class DynmapWorldGuardPlugin extends JavaPlugin {
45
48
private static Logger log ;
@@ -51,8 +54,7 @@ public class DynmapWorldGuardPlugin extends JavaPlugin {
51
54
WorldGuardPlugin wg ;
52
55
BooleanFlag boost_flag ;
53
56
int updatesPerTick = 20 ;
54
- ProfileCache pc ;
55
-
57
+
56
58
FileConfiguration cfg ;
57
59
MarkerSet set ;
58
60
long updperiod ;
@@ -70,6 +72,7 @@ public class DynmapWorldGuardPlugin extends JavaPlugin {
70
72
@ Override
71
73
public void onLoad () {
72
74
log = this .getLogger ();
75
+ this .registerCustomFlags ();
73
76
}
74
77
75
78
private static class AreaStyle {
@@ -109,13 +112,15 @@ public static void severe(String msg) {
109
112
}
110
113
111
114
private Map <String , AreaMarker > resareas = new HashMap <String , AreaMarker >();
115
+ private WorldGuardPlatform platform ;
116
+ public WorldGuardPlatform p ;
112
117
113
118
private String formatInfoWindow (ProtectedRegion region , AreaMarker m ) {
114
119
String v = "<div class=\" regioninfo\" >" +infowindow +"</div>" ;
115
120
v = v .replace ("%regionname%" , m .getLabel ());
116
- v = v .replace ("%playerowners%" , region .getOwners ().toPlayersString (pc ));
121
+ v = v .replace ("%playerowners%" , region .getOwners ().toPlayersString ());
117
122
v = v .replace ("%groupowners%" , region .getOwners ().toGroupsString ());
118
- v = v .replace ("%playermembers%" , region .getMembers ().toPlayersString (pc ));
123
+ v = v .replace ("%playermembers%" , region .getMembers ().toPlayersString ());
119
124
v = v .replace ("%groupmembers%" , region .getMembers ().toGroupsString ());
120
125
if (region .getParent () != null )
121
126
v = v .replace ("%parent%" , region .getParent ().getId ());
@@ -177,8 +182,7 @@ else if((tok.length >= 2) && resid.startsWith(tok[0]) && resid.endsWith(tok[1]))
177
182
}
178
183
}
179
184
if (as == null ) {
180
- for (UUID uuid : pd .getUniqueIds ()) {
181
- String p = resolveUUID (uuid );
185
+ for (String p : pd .getPlayers ()) {
182
186
if (p != null ) {
183
187
as = ownerstyle .get (p .toLowerCase ());
184
188
if (as != null ) break ;
@@ -226,15 +230,7 @@ else if((tok.length >= 2) && resid.startsWith(tok[0]) && resid.endsWith(tok[1]))
226
230
m .setBoostFlag ((b == null )?false :b .booleanValue ());
227
231
}
228
232
}
229
-
230
- private String resolveUUID (UUID uuid ) {
231
- Profile p = pc .getIfPresent (uuid );
232
- if (p != null ) {
233
- return p .getName ();
234
- }
235
- return null ;
236
- }
237
-
233
+
238
234
/* Handle specific region */
239
235
private void handleRegion (World world , ProtectedRegion region , Map <String , AreaMarker > newmap ) {
240
236
String name = region .getId ();
@@ -311,7 +307,11 @@ public void run() {
311
307
}
312
308
// If worlds list isn't primed, prime it
313
309
if (worldsToDo == null ) {
314
- worldsToDo = new ArrayList <World >(getServer ().getWorlds ());
310
+ List <org .bukkit .World > w = Bukkit .getWorlds ();
311
+ worldsToDo = new ArrayList <World >();
312
+ for (org .bukkit .World wrld : w ) {
313
+ worldsToDo .add (platform .getWorldByName (wrld .getName ()));
314
+ }
315
315
}
316
316
while (regionsToDo == null ) { // No pending regions for world
317
317
if (worldsToDo .isEmpty ()) { // No more worlds?
@@ -327,7 +327,8 @@ public void run() {
327
327
}
328
328
else {
329
329
curworld = worldsToDo .remove (0 );
330
- RegionManager rm = wg .getRegionManager (curworld ); /* Get region manager for world */
330
+ RegionContainer rc = platform .getRegionContainer ();
331
+ RegionManager rm = rc .get (curworld ); /* Get region manager for world */
331
332
if (rm != null ) {
332
333
Map <String ,ProtectedRegion > regions = rm .getRegions (); /* Get all the regions */
333
334
if ((regions != null ) && (regions .isEmpty () == false )) {
@@ -387,11 +388,11 @@ public void onEnable() {
387
388
return ;
388
389
}
389
390
wg = (WorldGuardPlugin )p ;
390
- pc = wg .getProfileCache ();
391
+
392
+ platform = WorldGuard .getInstance ().getPlatform ();
391
393
392
394
getServer ().getPluginManager ().registerEvents (new OurServerListener (), this );
393
395
394
- registerCustomFlags ();
395
396
/* If both enabled, activate */
396
397
if (dynmap .isEnabled () && wg .isEnabled ())
397
398
activate ();
@@ -403,28 +404,15 @@ public void onEnable() {
403
404
404
405
}
405
406
}
406
-
407
- private WGCustomFlagsPlugin getWGCustomFlags ()
408
- {
409
- Plugin plugin = getServer ().getPluginManager ().getPlugin ("WGCustomFlags" );
410
-
411
- if (plugin == null || !(plugin instanceof WGCustomFlagsPlugin ))
412
- {
413
- return null ;
414
- }
415
-
416
- return (WGCustomFlagsPlugin ) plugin ;
417
- }
418
407
419
408
private void registerCustomFlags () {
420
409
try {
421
- WGCustomFlagsPlugin cf = getWGCustomFlags ();
422
- if (cf != null ) {
423
- BooleanFlag bf = new BooleanFlag (BOOST_FLAG );
424
- cf .addCustomFlag (bf );
425
- boost_flag = bf ;
426
- }
410
+ BooleanFlag bf = new BooleanFlag (BOOST_FLAG );
411
+ FlagRegistry fr = WorldGuard .getInstance ().getFlagRegistry ();
412
+ fr .register (bf );
413
+ boost_flag = bf ;
427
414
} catch (Exception x ) {
415
+ log .info ("Error registering flag - " + x .getMessage ());
428
416
}
429
417
if (boost_flag == null ) {
430
418
log .info ("Custom flag '" + BOOST_FLAG + "' not registered - WGCustomFlags not found" );
0 commit comments