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:
parent
e1b2f7391c
commit
6b8e161e43
|
@ -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"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue