use of net.ess3.api.MaxMoneyException in project Essentials by drtshock.
the class Commandeco method take.
private void take(BigDecimal amount, final User player, final CommandSource sender) throws ChargeException {
BigDecimal money = player.getMoney();
BigDecimal minBalance = ess.getSettings().getMinMoney();
if (money.subtract(amount).compareTo(minBalance) > 0) {
player.takeMoney(amount, sender);
} else if (sender == null) {
try {
player.setMoney(minBalance);
} catch (MaxMoneyException ex) {
// Take shouldn't be able to throw a max money exception
}
player.sendMessage(tl("takenFromAccount", NumberUtil.displayCurrency(player.getMoney(), ess)));
} else {
throw new ChargeException(tl("insufficientFunds"));
}
}
use of net.ess3.api.MaxMoneyException in project Essentials by drtshock.
the class EssentialsSign method onSignBreak.
protected final boolean onSignBreak(final Block block, final Player player, final IEssentials ess) throws MaxMoneyException {
final ISign sign = new BlockSign(block);
final User user = ess.getUser(player);
try {
if (!(user.isAuthorized("essentials.signs." + signName.toLowerCase(Locale.ENGLISH) + ".break") || user.isAuthorized("essentials.signs.break." + signName.toLowerCase(Locale.ENGLISH)))) {
return false;
}
final SignBreakEvent signEvent = new SignBreakEvent(sign, this, user);
ess.getServer().getPluginManager().callEvent(signEvent);
if (signEvent.isCancelled()) {
return false;
}
return onSignBreak(sign, user, getUsername(user), ess);
} catch (SignException ex) {
showError(ess, user.getSource(), ex, signName);
return false;
}
}
use of net.ess3.api.MaxMoneyException in project Essentials by drtshock.
the class UserData method setMoney.
public void setMoney(BigDecimal value, boolean throwError) throws MaxMoneyException {
BigDecimal maxMoney = ess.getSettings().getMaxMoney();
BigDecimal minMoney = ess.getSettings().getMinMoney();
if (value.compareTo(maxMoney) > 0) {
if (throwError) {
throw new MaxMoneyException();
}
money = maxMoney;
} else {
money = value;
}
if (money.compareTo(minMoney) < 0) {
money = minMoney;
}
config.setProperty("money", money);
stopTransaction();
}
use of net.ess3.api.MaxMoneyException in project Essentials by EssentialsX.
the class EssentialsSign method onSignBreak.
protected final boolean onSignBreak(final Block block, final Player player, final IEssentials ess) throws MaxMoneyException {
final ISign sign = new BlockSign(block);
final User user = ess.getUser(player);
try {
if (!(user.isAuthorized("essentials.signs." + signName.toLowerCase(Locale.ENGLISH) + ".break") || user.isAuthorized("essentials.signs.break." + signName.toLowerCase(Locale.ENGLISH)))) {
return false;
}
final SignBreakEvent signEvent = new SignBreakEvent(sign, this, user);
ess.getServer().getPluginManager().callEvent(signEvent);
if (signEvent.isCancelled()) {
return false;
}
return onSignBreak(sign, user, getUsername(user), ess);
} catch (SignException ex) {
showError(ess, user.getSource(), ex, signName);
return false;
}
}
use of net.ess3.api.MaxMoneyException in project Essentials by EssentialsX.
the class UserData method setMoney.
public void setMoney(BigDecimal value, boolean throwError) throws MaxMoneyException {
BigDecimal maxMoney = ess.getSettings().getMaxMoney();
BigDecimal minMoney = ess.getSettings().getMinMoney();
if (value.compareTo(maxMoney) > 0) {
if (throwError) {
throw new MaxMoneyException();
}
money = maxMoney;
} else {
money = value;
}
if (money.compareTo(minMoney) < 0) {
money = minMoney;
}
config.setProperty("money", money);
stopTransaction();
}
Aggregations