From d17f3c0fbda87d54010be24edeb163c66b361ec1 Mon Sep 17 00:00:00 2001 From: Nick Minkler Date: Fri, 17 Jul 2020 10:34:56 -0700 Subject: [PATCH] Add null check on playernames for #782 Add a simple null check on playernames for deposit/withdraw to prevent NPEs in essentials economy even though they should be handled in essentials. --- .../milkbowl/vault/economy/plugins/Economy_Essentials.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/net/milkbowl/vault/economy/plugins/Economy_Essentials.java b/src/net/milkbowl/vault/economy/plugins/Economy_Essentials.java index 919927c..897d866 100644 --- a/src/net/milkbowl/vault/economy/plugins/Economy_Essentials.java +++ b/src/net/milkbowl/vault/economy/plugins/Economy_Essentials.java @@ -95,6 +95,9 @@ public class Economy_Essentials extends AbstractEconomy { @Override public EconomyResponse withdrawPlayer(String playerName, double amount) { + if (playerName == null) { + return new EconomyResponse(0, 0 ResponseType.FAILURE, "Player name can not be null."); + } if (amount < 0) { return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds"); } @@ -134,6 +137,9 @@ public class Economy_Essentials extends AbstractEconomy { } public EconomyResponse tryDepositPlayer(String playerName, double amount, int tries) { + if (playerName == null) { + return new EconomyResponse(0, 0 ResponseType.FAILURE, "Player name can not be null."); + } if (amount < 0) { return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds"); }