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