7
7
import java .util .List ;
8
8
import java .util .Map ;
9
9
import java .util .Set ;
10
+ import java .util .UUID ;
10
11
import java .util .logging .Level ;
11
12
import java .util .logging .Logger ;
12
13
30
31
import com .sk89q .worldedit .BlockVector2D ;
31
32
import com .sk89q .worldguard .bukkit .WorldGuardPlugin ;
32
33
import com .sk89q .worldguard .domains .DefaultDomain ;
34
+ import com .sk89q .worldguard .domains .PlayerDomain ;
33
35
import com .sk89q .worldguard .protection .flags .BooleanFlag ;
34
36
import com .sk89q .worldguard .protection .flags .Flag ;
35
37
import com .sk89q .worldguard .protection .managers .RegionManager ;
36
38
import com .sk89q .worldguard .protection .regions .ProtectedPolygonalRegion ;
37
39
import com .sk89q .worldguard .protection .regions .ProtectedRegion ;
38
40
import com .sk89q .worldguard .protection .regions .RegionType ;
41
+ import com .sk89q .worldguard .util .profile .Profile ;
42
+ import com .sk89q .worldguard .util .profile .cache .ProfileCache ;
39
43
40
44
public class DynmapWorldGuardPlugin extends JavaPlugin {
41
45
private static Logger log ;
@@ -47,6 +51,7 @@ public class DynmapWorldGuardPlugin extends JavaPlugin {
47
51
WorldGuardPlugin wg ;
48
52
BooleanFlag boost_flag ;
49
53
int updatesPerTick = 20 ;
54
+ ProfileCache pc ;
50
55
51
56
FileConfiguration cfg ;
52
57
MarkerSet set ;
@@ -108,9 +113,9 @@ public static void severe(String msg) {
108
113
private String formatInfoWindow (ProtectedRegion region , AreaMarker m ) {
109
114
String v = "<div class=\" regioninfo\" >" +infowindow +"</div>" ;
110
115
v = v .replace ("%regionname%" , m .getLabel ());
111
- v = v .replace ("%playerowners%" , region .getOwners ().toPlayersString ());
116
+ v = v .replace ("%playerowners%" , region .getOwners ().toPlayersString (pc ));
112
117
v = v .replace ("%groupowners%" , region .getOwners ().toGroupsString ());
113
- v = v .replace ("%playermembers%" , region .getMembers ().toPlayersString ());
118
+ v = v .replace ("%playermembers%" , region .getMembers ().toPlayersString (pc ));
114
119
v = v .replace ("%groupmembers%" , region .getMembers ().toGroupsString ());
115
120
if (region .getParent () != null )
116
121
v = v .replace ("%parent%" , region .getParent ().getId ());
@@ -157,19 +162,37 @@ else if((tok.length >= 2) && resid.startsWith(tok[0]) && resid.endsWith(tok[1]))
157
162
if (as == null ) { /* Check for owner style matches */
158
163
if (ownerstyle .isEmpty () != true ) {
159
164
DefaultDomain dd = region .getOwners ();
160
- Set < String > play = dd .getPlayers ();
161
- if (play != null ) {
162
- for (String p : play ) {
165
+ PlayerDomain pd = dd .getPlayerDomain ();
166
+ if (pd != null ) {
167
+ for (String p : pd . getPlayers () ) {
163
168
if (as == null ) {
164
169
as = ownerstyle .get (p .toLowerCase ());
170
+ if (as != null ) break ;
171
+ }
172
+ }
173
+ if (as == null ) {
174
+ for (UUID uuid : pd .getUniqueIds ()) {
175
+ as = ownerstyle .get (uuid .toString ());
176
+ if (as != null ) break ;
177
+ }
178
+ }
179
+ if (as == null ) {
180
+ for (UUID uuid : pd .getUniqueIds ()) {
181
+ String p = resolveUUID (uuid );
182
+ if (p != null ) {
183
+ as = ownerstyle .get (p .toLowerCase ());
184
+ if (as != null ) break ;
185
+ }
165
186
}
166
187
}
167
188
}
168
- Set < String > grp = dd . getGroups ();
169
- if ( grp != null ) {
170
- for ( String p : grp ) {
171
- if ( as == null )
189
+ if ( as == null ) {
190
+ Set < String > grp = dd . getGroups ();
191
+ if ( grp != null ) {
192
+ for ( String p : grp ) {
172
193
as = ownerstyle .get (p .toLowerCase ());
194
+ if (as != null ) break ;
195
+ }
173
196
}
174
197
}
175
198
}
@@ -203,6 +226,14 @@ else if((tok.length >= 2) && resid.startsWith(tok[0]) && resid.endsWith(tok[1]))
203
226
}
204
227
}
205
228
229
+ private String resolveUUID (UUID uuid ) {
230
+ Profile p = pc .getIfPresent (uuid );
231
+ if (p != null ) {
232
+ return p .getName ();
233
+ }
234
+ return null ;
235
+ }
236
+
206
237
/* Handle specific region */
207
238
private void handleRegion (World world , ProtectedRegion region , Map <String , AreaMarker > newmap ) {
208
239
String name = region .getId ();
@@ -353,7 +384,8 @@ public void onEnable() {
353
384
return ;
354
385
}
355
386
wg = (WorldGuardPlugin )p ;
356
-
387
+ pc = wg .getProfileCache ();
388
+
357
389
getServer ().getPluginManager ().registerEvents (new OurServerListener (), this );
358
390
359
391
registerCustomFlags ();
0 commit comments