From 50e2d27d5bbd7a331a0b3d0096004aa7dd6dd3dc Mon Sep 17 00:00:00 2001 From: Drew Mitchell Date: Sat, 6 Jan 2018 19:45:19 -0600 Subject: [PATCH] Fix NPE in /clearinventory. Fixes #1755 (#1756) Issue was a NullPointerException due to senderUser not being null-checked. I opted to place the couple of lines of code into the sender.isPlayer() check as opposed to null-checking. --- .../essentials/commands/Commandclearinventory.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java index 6de51fe12..e5a433f09 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java @@ -43,13 +43,15 @@ public class Commandclearinventory extends EssentialsCommand { throws Exception { Collection players = new ArrayList(); User senderUser = ess.getUser(sender.getPlayer()); - // Clear previous command execution before potential errors to reset confirmation. - String previousClearCommand = senderUser.getConfirmingClearCommand(); - senderUser.setConfirmingClearCommand(null); + String previousClearCommand = ""; + int offset = 0; if (sender.isPlayer()) { players.add(sender.getPlayer()); + // Clear previous command execution before potential errors to reset confirmation. + previousClearCommand = senderUser.getConfirmingClearCommand(); + senderUser.setConfirmingClearCommand(null); } if (allowAll && args.length > 0 && args[0].contentEquals("*")) {