Ignore formatting when parsing sign lines (#503)

This commit is contained in:
Phoenix616 2022-02-17 21:29:43 +01:00
parent 2ebc2f285b
commit 4c7b018f8c
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0

View File

@ -183,7 +183,7 @@ public class ChestShopSign {
for (int i = 0; i < 3; i++) {
boolean matches = false;
for (Pattern pattern : SHOP_SIGN_PATTERN[i]) {
if (pattern.matcher(lines[i+1]).matches()) {
if (pattern.matcher(StringUtils.strip(StringUtil.stripColourCodes(lines[i+1]))).matches()) {
matches = true;
break;
}
@ -213,7 +213,7 @@ public class ChestShopSign {
* @return The owner string
*/
public static String getOwner(String[] lines) {
return StringUtil.stripColourCodes(StringUtils.strip(lines[NAME_LINE]));
return StringUtil.stripColourCodes(StringUtils.strip(StringUtil.stripColourCodes(lines[NAME_LINE])));
}
/**
@ -233,7 +233,7 @@ public class ChestShopSign {
* @throws IllegalArgumentException Thrown when an invalid quantity is present
*/
public static String getQuantityLine(String[] lines) throws IllegalArgumentException {
return lines.length > QUANTITY_LINE ? StringUtils.strip(lines[QUANTITY_LINE]) : "";
return lines.length > QUANTITY_LINE ? StringUtils.strip(StringUtil.stripColourCodes(lines[QUANTITY_LINE])) : "";
}
/**
@ -262,7 +262,7 @@ public class ChestShopSign {
* @return The price line
*/
public static String getPrice(Sign sign) {
return StringUtils.strip(sign.getLine(PRICE_LINE));
return StringUtils.strip(StringUtil.stripColourCodes(sign.getLine(PRICE_LINE)));
}
/**
@ -271,7 +271,7 @@ public class ChestShopSign {
* @return The price line
*/
public static String getPrice(String[] lines) {
return lines.length > PRICE_LINE ? StringUtils.strip(lines[PRICE_LINE]) : "";
return lines.length > PRICE_LINE ? StringUtils.strip(StringUtil.stripColourCodes(lines[PRICE_LINE])) : "";
}
/**
@ -289,6 +289,6 @@ public class ChestShopSign {
* @return The item line
*/
public static String getItem(String[] lines) {
return lines.length > ITEM_LINE ? StringUtils.strip(lines[ITEM_LINE]) : "";
return lines.length > ITEM_LINE ? StringUtils.strip(StringUtil.stripColourCodes(lines[ITEM_LINE])) : "";
}
}