mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-24 06:23:59 +00:00
Catch both exceptions in EssentialsConf and valueOf instead of new
This commit is contained in:
parent
0d34b9ae9f
commit
b49aaee66d
4 changed files with 9 additions and 5 deletions
|
@ -542,6 +542,10 @@ public class EssentialsConf extends YamlConfiguration
|
||||||
{
|
{
|
||||||
return new BigDecimal(input, MathContext.DECIMAL128);
|
return new BigDecimal(input, MathContext.DECIMAL128);
|
||||||
}
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
return def;
|
||||||
|
}
|
||||||
catch (ArithmeticException e)
|
catch (ArithmeticException e)
|
||||||
{
|
{
|
||||||
return def;
|
return def;
|
||||||
|
|
|
@ -184,7 +184,7 @@ public class Trade
|
||||||
if (command != null)
|
if (command != null)
|
||||||
{
|
{
|
||||||
final BigDecimal cost = getCommandCost(user);
|
final BigDecimal cost = getCommandCost(user);
|
||||||
if (!user.canAfford(cost) && cost.compareTo(BigDecimal.ZERO) > 0)
|
if (!user.canAfford(cost) && cost.signum() > 0)
|
||||||
{
|
{
|
||||||
throw new ChargeException(_("notEnoughMoney"));
|
throw new ChargeException(_("notEnoughMoney"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,11 +147,11 @@ public class Commandsell extends EssentialsCommand
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return worth.multiply(new BigDecimal(amount));
|
return worth.multiply(BigDecimal.valueOf(amount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal result = worth.multiply(new BigDecimal(amount));
|
BigDecimal result = worth.multiply(BigDecimal.valueOf(amount));
|
||||||
//TODO: Prices for Enchantments
|
//TODO: Prices for Enchantments
|
||||||
final ItemStack ris = is.clone();
|
final ItemStack ris = is.clone();
|
||||||
ris.setAmount(amount);
|
ris.setAmount(amount);
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class Commandworth extends EssentialsCommand
|
||||||
throw new Exception(_("itemCannotBeSold"));
|
throw new Exception(_("itemCannotBeSold"));
|
||||||
}
|
}
|
||||||
|
|
||||||
final BigDecimal result = worth.multiply(new BigDecimal(amount));
|
final BigDecimal result = worth.multiply(BigDecimal.valueOf(amount));
|
||||||
|
|
||||||
user.sendMessage(iStack.getDurability() != 0
|
user.sendMessage(iStack.getDurability() != 0
|
||||||
? _("worthMeta",
|
? _("worthMeta",
|
||||||
|
@ -94,7 +94,7 @@ public class Commandworth extends EssentialsCommand
|
||||||
throw new Exception(_("itemCannotBeSold"));
|
throw new Exception(_("itemCannotBeSold"));
|
||||||
}
|
}
|
||||||
|
|
||||||
final BigDecimal result = worth.multiply(new BigDecimal(amount));
|
final BigDecimal result = worth.multiply(BigDecimal.valueOf(amount));
|
||||||
|
|
||||||
sender.sendMessage(iStack.getDurability() != 0
|
sender.sendMessage(iStack.getDurability() != 0
|
||||||
? _("worthMeta",
|
? _("worthMeta",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue