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.
This commit is contained in:
Drew Mitchell 2018-01-06 19:45:19 -06:00 committed by Ali 'SupaHam' M
parent fd6717d06d
commit 50e2d27d5b

View File

@ -43,13 +43,15 @@ public class Commandclearinventory extends EssentialsCommand {
throws Exception {
Collection<Player> players = new ArrayList<Player>();
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("*")) {