Ensure buy/rent/resell price is never below zero

This prevents problems with negative payment or withdrawal in Vault if input validation of a command is not good enough or if a price has manually been set below zero.
This commit is contained in:
Thijs Wiefferink 2017-02-02 17:18:26 +01:00
parent e1b2f7391c
commit 6b8e161e43
2 changed files with 3 additions and 3 deletions

View File

@ -129,7 +129,7 @@ public class BuyRegion extends GeneralRegion {
* @return The price of the region
*/
public double getPrice() {
return Utils.evaluateToDouble(getStringSetting("buy.price"), this);
return Math.max(0, Utils.evaluateToDouble(getStringSetting("buy.price"), this));
}
/**
@ -137,7 +137,7 @@ public class BuyRegion extends GeneralRegion {
* @return The resell price if isInResellingMode(), otherwise 0.0
*/
public double getResellPrice() {
return config.getDouble("buy.resellPrice");
return Math.max(0, config.getDouble("buy.resellPrice"));
}
/**

View File

@ -222,7 +222,7 @@ public class RentRegion extends GeneralRegion {
* @return The price of the region
*/
public double getPrice() {
return Utils.evaluateToDouble(getStringSetting("rent.price"), this);
return Math.max(0, Utils.evaluateToDouble(getStringSetting("rent.price"), this));
}
/**