From 20bbdfc4ab959d40a2feb5916f0f109a01b02fc7 Mon Sep 17 00:00:00 2001 From: Gio Date: Mon, 30 Apr 2018 12:54:35 -0500 Subject: [PATCH 1/2] Check playerdata for corruption Fixed a null pointer exception that would occur if the offlinePlayer object did not have a defined string for .getName(); --- .../java/com/gmail/nossr50/util/commands/CommandUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index 76dd50bdf..29aa05b91 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -296,6 +296,11 @@ public final class CommandUtils { for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) { String playerName = offlinePlayer.getName(); + + if (playerName == null) { //Do null checking here to detect corrupted data before sending it throuogh .equals + System.err.println("[McMMO] Bad player data file with UIID " + offlinePlayer.getUniqueId() ); + continue; //Don't let an error here interrupt the loop + } if (partialName.equalsIgnoreCase(playerName)) { // Exact match From 2c6543da9e1c4fe5d30565d1c2feb348d0f0a469 Mon Sep 17 00:00:00 2001 From: Gio Date: Mon, 30 Apr 2018 13:30:41 -0500 Subject: [PATCH 2/2] More descriptive text. --- src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index 29aa05b91..41d534ceb 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -298,7 +298,7 @@ public final class CommandUtils { String playerName = offlinePlayer.getName(); if (playerName == null) { //Do null checking here to detect corrupted data before sending it throuogh .equals - System.err.println("[McMMO] Bad player data file with UIID " + offlinePlayer.getUniqueId() ); + System.err.println("[McMMO] Player data file with UIID " + offlinePlayer.getUniqueId() + " is missing a player name. This may be a legacy file from before bukkit.lastKnownName. This should be okay to ignore."); continue; //Don't let an error here interrupt the loop }