Skip to content

Commit

Permalink
Add null check on playernames for #782
Browse files Browse the repository at this point in the history
Add a simple null check on playernames for deposit/withdraw to prevent NPEs in essentials economy even though they should be handled in essentials.
  • Loading branch information
Sleaker authored Jul 17, 2020
1 parent 2a85b77 commit d17f3c0
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public boolean createPlayerAccount(String playerName) {

@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");
}
Expand Down Expand Up @@ -134,6 +137,9 @@ public EconomyResponse withdrawPlayer(String playerName, double amount) {
}

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

0 comments on commit d17f3c0

Please sign in to comment.