Skip to content

Commit 57075ee

Browse files
committed
Add handling for UUID owners and members
1 parent c8a1abc commit 57075ee

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

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

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.List;
88
import java.util.Map;
99
import java.util.Set;
10+
import java.util.UUID;
1011
import java.util.logging.Level;
1112
import java.util.logging.Logger;
1213

@@ -30,12 +31,15 @@
3031
import com.sk89q.worldedit.BlockVector2D;
3132
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
3233
import com.sk89q.worldguard.domains.DefaultDomain;
34+
import com.sk89q.worldguard.domains.PlayerDomain;
3335
import com.sk89q.worldguard.protection.flags.BooleanFlag;
3436
import com.sk89q.worldguard.protection.flags.Flag;
3537
import com.sk89q.worldguard.protection.managers.RegionManager;
3638
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
3739
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
3840
import com.sk89q.worldguard.protection.regions.RegionType;
41+
import com.sk89q.worldguard.util.profile.Profile;
42+
import com.sk89q.worldguard.util.profile.cache.ProfileCache;
3943

4044
public class DynmapWorldGuardPlugin extends JavaPlugin {
4145
private static Logger log;
@@ -47,6 +51,7 @@ public class DynmapWorldGuardPlugin extends JavaPlugin {
4751
WorldGuardPlugin wg;
4852
BooleanFlag boost_flag;
4953
int updatesPerTick = 20;
54+
ProfileCache pc;
5055

5156
FileConfiguration cfg;
5257
MarkerSet set;
@@ -108,9 +113,9 @@ public static void severe(String msg) {
108113
private String formatInfoWindow(ProtectedRegion region, AreaMarker m) {
109114
String v = "<div class=\"regioninfo\">"+infowindow+"</div>";
110115
v = v.replace("%regionname%", m.getLabel());
111-
v = v.replace("%playerowners%", region.getOwners().toPlayersString());
116+
v = v.replace("%playerowners%", region.getOwners().toPlayersString(pc));
112117
v = v.replace("%groupowners%", region.getOwners().toGroupsString());
113-
v = v.replace("%playermembers%", region.getMembers().toPlayersString());
118+
v = v.replace("%playermembers%", region.getMembers().toPlayersString(pc));
114119
v = v.replace("%groupmembers%", region.getMembers().toGroupsString());
115120
if(region.getParent() != null)
116121
v = v.replace("%parent%", region.getParent().getId());
@@ -157,19 +162,37 @@ else if((tok.length >= 2) && resid.startsWith(tok[0]) && resid.endsWith(tok[1]))
157162
if(as == null) { /* Check for owner style matches */
158163
if(ownerstyle.isEmpty() != true) {
159164
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()) {
163168
if(as == null) {
164169
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+
}
165186
}
166187
}
167188
}
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) {
172193
as = ownerstyle.get(p.toLowerCase());
194+
if (as != null) break;
195+
}
173196
}
174197
}
175198
}
@@ -203,6 +226,14 @@ else if((tok.length >= 2) && resid.startsWith(tok[0]) && resid.endsWith(tok[1]))
203226
}
204227
}
205228

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+
206237
/* Handle specific region */
207238
private void handleRegion(World world, ProtectedRegion region, Map<String, AreaMarker> newmap) {
208239
String name = region.getId();
@@ -353,7 +384,8 @@ public void onEnable() {
353384
return;
354385
}
355386
wg = (WorldGuardPlugin)p;
356-
387+
pc = wg.getProfileCache();
388+
357389
getServer().getPluginManager().registerEvents(new OurServerListener(), this);
358390

359391
registerCustomFlags();

0 commit comments

Comments
 (0)