From 11facab71c0d9854082de5db7f78a0fc78270de6 Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 10 Oct 2016 22:26:39 +0100 Subject: [PATCH] Fix NPE, resolves #19 --- .../java/me/lucko/luckperms/storage/methods/JSONDatastore.java | 2 +- .../me/lucko/luckperms/storage/methods/MongoDBDatastore.java | 2 +- .../java/me/lucko/luckperms/storage/methods/SQLDatastore.java | 2 +- .../java/me/lucko/luckperms/storage/methods/YAMLDatastore.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/storage/methods/JSONDatastore.java b/common/src/main/java/me/lucko/luckperms/storage/methods/JSONDatastore.java index 63d82e0c..fb0636cb 100644 --- a/common/src/main/java/me/lucko/luckperms/storage/methods/JSONDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/storage/methods/JSONDatastore.java @@ -103,7 +103,7 @@ public class JSONDatastore extends FlatfileDatastore { boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false); - if (user.getName().equalsIgnoreCase("null")) { + if (user.getName() == null || user.getName().equalsIgnoreCase("null")) { user.setName(name1); } else { if (!name1.equals(user.getName())) { diff --git a/common/src/main/java/me/lucko/luckperms/storage/methods/MongoDBDatastore.java b/common/src/main/java/me/lucko/luckperms/storage/methods/MongoDBDatastore.java index 79ab53e8..c73cfe2a 100644 --- a/common/src/main/java/me/lucko/luckperms/storage/methods/MongoDBDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/storage/methods/MongoDBDatastore.java @@ -156,7 +156,7 @@ public class MongoDBDatastore extends Datastore { boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false); - if (user.getName().equalsIgnoreCase("null")) { + if (user.getName() == null || user.getName().equalsIgnoreCase("null")) { user.setName(d.getString("name")); } else { if (!d.getString("name").equals(user.getName())) { diff --git a/common/src/main/java/me/lucko/luckperms/storage/methods/SQLDatastore.java b/common/src/main/java/me/lucko/luckperms/storage/methods/SQLDatastore.java index 36c7bb93..824c7ec2 100644 --- a/common/src/main/java/me/lucko/luckperms/storage/methods/SQLDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/storage/methods/SQLDatastore.java @@ -157,7 +157,7 @@ abstract class SQLDatastore extends Datastore { boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false); - if (user.getName().equalsIgnoreCase("null")) { + if (user.getName() == null || user.getName().equalsIgnoreCase("null")) { user.setName(resultSet.getString("name")); } else { if (!resultSet.getString("name").equals(user.getName())) { diff --git a/common/src/main/java/me/lucko/luckperms/storage/methods/YAMLDatastore.java b/common/src/main/java/me/lucko/luckperms/storage/methods/YAMLDatastore.java index a5d7d9d7..64be5a07 100644 --- a/common/src/main/java/me/lucko/luckperms/storage/methods/YAMLDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/storage/methods/YAMLDatastore.java @@ -97,7 +97,7 @@ public class YAMLDatastore extends FlatfileDatastore { boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false); - if (user.getName().equalsIgnoreCase("null")) { + if (user.getName() == null || user.getName().equalsIgnoreCase("null")) { user.setName(name); } else { if (!name.equals(user.getName())) {