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.
This commit is contained in:
Nick Minkler 2020-07-17 10:34:56 -07:00 committed by GitHub
parent 2a85b772ef
commit d17f3c0fbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -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");
}