Skip to content

Commit 7c3bbe5

Browse files
committed
Fixed: Handle corrupted user files in searches
1 parent 9206518 commit 7c3bbe5

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ public void run() {
7474
if (pip == null) continue;
7575
if (pip.contains(ip)) {
7676
synchronized (hasIP) {
77-
hasIP.add(pcm.getString("name", op.getName()) + ((partial) ? MessageColor.POSITIVE + ": " + MessageColor.NEUTRAL + pip : ""));
77+
String name = "";
78+
try {
79+
name = op.getName();
80+
} catch (Exception e) {
81+
name = op.getUniqueId().toString();
82+
}
83+
hasIP.add(pcm.getString("name", name) + ((partial) ? MessageColor.POSITIVE + ": " + MessageColor.NEUTRAL + pip : ""));
7884
}
7985
}
8086
if (!alreadyPresent) pcm.discard();

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ public void run() {
4141
int found = 0;
4242
cs.sendMessage(MessageColor.POSITIVE + "Search for " + MessageColor.NEUTRAL + search + MessageColor.POSITIVE + " started. This may take a while.");
4343
for (final OfflinePlayer op : ops) {
44-
if (op == null || op.getName() == null) continue;
44+
try {
45+
if (op == null || op.getName() == null) continue;
46+
} catch (Exception ex) {
47+
cs.sendMessage(MessageColor.NEGATIVE + "Failed to read " + MessageColor.NEUTRAL + op.getUniqueId());
48+
continue;
49+
}
4550
if (!op.getName().toLowerCase().contains(search.toLowerCase())) continue;
4651
PlayerConfiguration pcm = PlayerConfigurationManager.getConfiguration(op);
4752
if (!pcm.exists()) continue;

0 commit comments

Comments
 (0)