Update com/Acrobot/ChestShop/Signs/ChestShopSign.java

Fixes problems with isValid() when used on a sign which has it's price line formatted with lower case letters. Also, uses RegEx to check the price line is valid.
This commit is contained in:
meiamsome 2012-08-14 02:52:56 +02:00
parent 7629c1bc4b
commit ebfcfd56f0

View File

@ -23,7 +23,7 @@ public class ChestShopSign {
public static final Pattern[] SHOP_SIGN_PATTERN = { public static final Pattern[] SHOP_SIGN_PATTERN = {
Pattern.compile("^$|^\\w.+$"), Pattern.compile("^$|^\\w.+$"),
Pattern.compile("[0-9]+"), Pattern.compile("[0-9]+"),
Pattern.compile(".+"), Pattern.compile("(?i)(((b *[0-9]+)|([0-9]+ *b))|((s *[0-9]+)|([0-9]+ *s)))|((((b *[0-9]+)|([0-9]+ *b))[ ]*:[ ]*((s *[0-9]+)|([0-9]+ *s))))"),
Pattern.compile("[\\w : -]+") Pattern.compile("[\\w : -]+")
}; };
@ -40,7 +40,7 @@ public class ChestShopSign {
} }
public static boolean isValid(String[] line) { public static boolean isValid(String[] line) {
return isValidPreparedSign(line) && (line[2].contains("B") || line[2].contains("S")) && !line[0].isEmpty(); return isValidPreparedSign(line) && !line[0].isEmpty();
} }
public static boolean isValid(Block sign) { public static boolean isValid(Block sign) {
@ -60,6 +60,5 @@ public class ChestShopSign {
return false; return false;
} }
} }
return lines[2].indexOf(':') == lines[2].lastIndexOf(':');
} }
} }