Make numeric regexes require at least one number to match.

This commit is contained in:
garbagemule 2014-12-08 16:45:05 +01:00
parent 55e0500bae
commit 243c5ea6ea

View File

@ -92,7 +92,7 @@ public class PotionEffectParser
private static PotionEffectType getType(String type) { private static PotionEffectType getType(String type) {
PotionEffectType effect = null; PotionEffectType effect = null;
if (type.matches("[0-9]*")) { if (type.matches("[0-9]+")) {
effect = PotionEffectType.getById(Integer.parseInt(type)); effect = PotionEffectType.getById(Integer.parseInt(type));
} else { } else {
effect = PotionEffectType.getByName(type.toUpperCase()); effect = PotionEffectType.getByName(type.toUpperCase());
@ -104,7 +104,7 @@ public class PotionEffectParser
private static int getDuration(String duration) { private static int getDuration(String duration) {
int dur = -1; int dur = -1;
if (duration.matches("[0-9]*")) { if (duration.matches("[0-9]+")) {
dur = Integer.parseInt(duration); dur = Integer.parseInt(duration);
} }
@ -114,7 +114,7 @@ public class PotionEffectParser
private static int getAmplification(String amplifier) { private static int getAmplification(String amplifier) {
int amp = -1; int amp = -1;
if (amplifier.matches("[0-9]*")) { if (amplifier.matches("[0-9]+")) {
amp = Integer.parseInt(amplifier); amp = Integer.parseInt(amplifier);
} }