summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-06-08 03:44:16 +0200
committersnowleo <schneeleo@gmail.com>2011-06-08 03:44:16 +0200
commitdea44d7cbcac7571fef43c98a98975853fb08201 (patch)
treee87c79cca511cf211bdfdf1417046a08caea55a0
parente0597f2df1f2f8a603e4ba665205aef7a6d2ff3f (diff)
downloadEssentials-dea44d7cbcac7571fef43c98a98975853fb08201.tar
Essentials-dea44d7cbcac7571fef43c98a98975853fb08201.tar.gz
Essentials-dea44d7cbcac7571fef43c98a98975853fb08201.tar.lz
Essentials-dea44d7cbcac7571fef43c98a98975853fb08201.tar.xz
Essentials-dea44d7cbcac7571fef43c98a98975853fb08201.zip
Catch NumberFormatException
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java54
1 files changed, 34 insertions, 20 deletions
diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
index f5a88467c..a5dff46d7 100644
--- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
+++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
@@ -136,17 +136,24 @@ public class EssentialsSign
{
throw new SignException(Util.i18n("invalidCharge"));
}
- final int quantity = Integer.parseInt(split[0]);
- if (quantity <= 1)
+ try
{
- throw new SignException(Util.i18n("moreThanZero"));
+ final int quantity = Integer.parseInt(split[0]);
+ if (quantity <= 1)
+ {
+ throw new SignException(Util.i18n("moreThanZero"));
+ }
+ final String item = split[1].toLowerCase();
+ if (!item.equalsIgnoreCase("times"))
+ {
+ getItemStack(item);
+ }
+ sign.setLine(index, quantity + " " + item);
}
- final String item = split[1].toLowerCase();
- if (!item.equalsIgnoreCase("times"))
+ catch (NumberFormatException ex)
{
- getItemStack(item);
+ throw new SignException(Util.i18n("invalidCharge"), ex);
}
- sign.setLine(index, quantity + " " + item);
}
}
@@ -187,22 +194,29 @@ public class EssentialsSign
{
throw new SignException(Util.i18n("invalidCharge"));
}
- final int quantity = Integer.parseInt(split[0]);
- if (quantity <= 1)
- {
- throw new SignException(Util.i18n("moreThanZero"));
- }
- final String item = split[1].toLowerCase();
- if (item.equalsIgnoreCase("times"))
+ try
{
- sign.setLine(index, (quantity - 1) + " times");
- return new Charge(signName.toLowerCase() + "sign", ess);
+ final int quantity = Integer.parseInt(split[0]);
+ if (quantity <= 1)
+ {
+ throw new SignException(Util.i18n("moreThanZero"));
+ }
+ final String item = split[1].toLowerCase();
+ if (item.equalsIgnoreCase("times"))
+ {
+ sign.setLine(index, (quantity - 1) + " times");
+ return new Charge(signName.toLowerCase() + "sign", ess);
+ }
+ else
+ {
+ final ItemStack stack = getItemStack(item);
+ stack.setAmount(quantity);
+ return new Charge(quantity, ess);
+ }
}
- else
+ catch (NumberFormatException ex)
{
- final ItemStack stack = getItemStack(item);
- stack.setAmount(quantity);
- return new Charge(quantity, ess);
+ throw new SignException(Util.i18n("invalidCharge"), ex);
}
}
}