Browse Source

Check playerdata for corruption

Fixed a null pointer exception that would occur if the offlinePlayer object did not have a defined string for .getName();
Gio 7 years ago
parent
commit
20bbdfc4ab
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java

+ 5 - 0
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