mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-13 11:41:24 +01:00
Renamed getInteger method name to getIntegerPositive.
This commit is contained in:
parent
a6d60dbc94
commit
fafd9b20a9
@ -267,7 +267,7 @@ public class EssentialsSign
|
||||
{
|
||||
|
||||
final ItemStack item = getItemStack(sign.getLine(itemIndex), 1);
|
||||
final int amount = Math.min(getInteger(sign.getLine(amountIndex)), item.getType().getMaxStackSize() * player.getInventory().getSize());
|
||||
final int amount = Math.min(getIntegerPositive(sign.getLine(amountIndex)), item.getType().getMaxStackSize() * player.getInventory().getSize());
|
||||
if (item.getTypeId() == 0 || amount < 1)
|
||||
{
|
||||
throw new SignException(Util.i18n("moreThanZero"));
|
||||
@ -283,19 +283,26 @@ public class EssentialsSign
|
||||
{
|
||||
throw new SignException("Empty line " + index);
|
||||
}
|
||||
final int quantity = getInteger(line);
|
||||
final int quantity = getIntegerPositive(line);
|
||||
sign.setLine(index, Integer.toString(quantity));
|
||||
}
|
||||
|
||||
protected final int getIntegerPositive(final String line) throws SignException
|
||||
{
|
||||
final int quantity = getInteger(line);
|
||||
if (quantity <= 1)
|
||||
{
|
||||
throw new SignException(Util.i18n("moreThanZero"));
|
||||
}
|
||||
return quantity;
|
||||
}
|
||||
|
||||
protected final int getInteger(final String line) throws SignException
|
||||
{
|
||||
try
|
||||
{
|
||||
final int quantity = Integer.parseInt(line);
|
||||
if (quantity <= 1)
|
||||
{
|
||||
throw new SignException(Util.i18n("moreThanZero"));
|
||||
}
|
||||
|
||||
return quantity;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
@ -362,7 +369,7 @@ public class EssentialsSign
|
||||
{
|
||||
throw new SignException(Util.i18n("invalidCharge"));
|
||||
}
|
||||
final int quantity = getInteger(split[0]);
|
||||
final int quantity = getIntegerPositive(split[0]);
|
||||
|
||||
final String item = split[1].toLowerCase();
|
||||
if (item.equalsIgnoreCase("times"))
|
||||
@ -380,6 +387,9 @@ public class EssentialsSign
|
||||
else
|
||||
{
|
||||
return new Trade(money, ess);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class SignTrade extends EssentialsSign
|
||||
|
||||
if (split.length == 2 && !amountNeeded)
|
||||
{
|
||||
final int amount = getInteger(split[0]);
|
||||
final int amount = getIntegerPositive(split[0]);
|
||||
final ItemStack item = getItemStack(split[1], amount);
|
||||
if (amount < 1 || item.getTypeId() == 0)
|
||||
{
|
||||
@ -110,9 +110,9 @@ public class SignTrade extends EssentialsSign
|
||||
|
||||
if (split.length == 3 && amountNeeded)
|
||||
{
|
||||
final int stackamount = getInteger(split[0]);
|
||||
final int stackamount = getIntegerPositive(split[0]);
|
||||
final ItemStack item = getItemStack(split[1], stackamount);
|
||||
int amount = getInteger(split[2]);
|
||||
int amount = getIntegerPositive(split[2]);
|
||||
amount -= amount % stackamount;
|
||||
if (amount < 1 || stackamount < 1 || item.getTypeId() == 0)
|
||||
{
|
||||
@ -145,9 +145,9 @@ public class SignTrade extends EssentialsSign
|
||||
|
||||
if (split.length == 3)
|
||||
{
|
||||
final int stackamount = getInteger(split[0]);
|
||||
final int stackamount = getIntegerPositive(split[0]);
|
||||
final ItemStack item = getItemStack(split[1], stackamount);
|
||||
int amount = getInteger(split[2]);
|
||||
int amount = getIntegerPositive(split[2]);
|
||||
amount -= amount % stackamount;
|
||||
if (amount < 1 || stackamount < 1 || item.getTypeId() == 0)
|
||||
{
|
||||
@ -209,7 +209,7 @@ public class SignTrade extends EssentialsSign
|
||||
|
||||
if (split.length == 3)
|
||||
{
|
||||
final int stackamount = getInteger(split[0]);
|
||||
final int stackamount = getIntegerPositive(split[0]);
|
||||
final ItemStack item = getItemStack(split[1], stackamount);
|
||||
int amount = getInteger(split[2]);
|
||||
sign.setLine(index, stackamount + " " + split[1] + ":" + (amount + Math.round(value)));
|
||||
|
Loading…
Reference in New Issue
Block a user