From 50c4d04b0242561b3b46a9d93ea653ee04154815 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Fri, 10 Nov 2023 19:27:06 -0500 Subject: [PATCH] Prevent possible NPE during legacy file conversion (#5551) Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com> --- .../essentials/config/EssentialsUserConfiguration.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/config/EssentialsUserConfiguration.java b/Essentials/src/main/java/com/earth2me/essentials/config/EssentialsUserConfiguration.java index eac64cc19ed..c8277e242de 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/config/EssentialsUserConfiguration.java +++ b/Essentials/src/main/java/com/earth2me/essentials/config/EssentialsUserConfiguration.java @@ -34,6 +34,9 @@ public void setUsername(final String username) { @Override public boolean legacyFileExists() { + if (username == null) { + return false; + } return new File(configFile.getParentFile(), username + ".yml").exists(); } @@ -57,7 +60,7 @@ private File getAltFile() { @Override public boolean altFileExists() { - if (username.equals(username.toLowerCase())) { + if (username == null || username.equals(username.toLowerCase())) { return false; } return getAltFile().exists();