Skip to content

Commit b8958b3

Browse files
committed
Updated: Support whois lookup by UUID
Also handles corrupted user files too.
1 parent 7c3bbe5 commit b8958b3

File tree

1 file changed

+16
-3
lines changed
  • modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/rcommands

1 file changed

+16
-3
lines changed

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/rcommands/CmdWhois.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
import java.text.DecimalFormat;
99
import java.util.Date;
10+
import java.util.UUID;
11+
1012
import org.apache.commons.lang3.BooleanUtils;
13+
import org.bukkit.Bukkit;
1114
import org.bukkit.Location;
1215
import org.bukkit.Material;
1316
import org.bukkit.OfflinePlayer;
@@ -36,9 +39,19 @@ public boolean runCommand(final CommandSender cs, final Command cmd, final Strin
3639
cs.sendMessage(cmd.getDescription());
3740
return false;
3841
}
39-
final OfflinePlayer t = RUtils.getOfflinePlayer(args[0]);
40-
if (!t.isOnline() && !t.hasPlayedBefore()) {
41-
cs.sendMessage(MessageColor.NEGATIVE + "That player has never played before!");
42+
OfflinePlayer t = null;
43+
if (args[0].matches("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}")) {
44+
t = Bukkit.getOfflinePlayer(UUID.fromString(args[0]));
45+
} else {
46+
t = RUtils.getOfflinePlayer(args[0]);
47+
}
48+
try {
49+
if (t == null || !t.isOnline() && !t.hasPlayedBefore()) {
50+
cs.sendMessage(MessageColor.NEGATIVE + "That player has never played before!");
51+
return true;
52+
}
53+
} catch (Exception e) {
54+
cs.sendMessage(MessageColor.NEGATIVE + "That player's data is unreadable!");
4255
return true;
4356
}
4457
PlayerConfiguration pcm = PlayerConfigurationManager.getConfiguration(t);

0 commit comments

Comments
 (0)