mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-02-15 18:01:22 +01:00
Add a system to fix invalid signs
This commit is contained in:
parent
7865b26173
commit
d66f6b95d2
@ -21,7 +21,7 @@ public class PriceUtil {
|
|||||||
*/
|
*/
|
||||||
public static double get(String text, char indicator) {
|
public static double get(String text, char indicator) {
|
||||||
String[] split = text.replace(" ", "").toLowerCase().split(":");
|
String[] split = text.replace(" ", "").toLowerCase().split(":");
|
||||||
String character = String.valueOf(indicator);
|
String character = String.valueOf(indicator).toLowerCase();
|
||||||
|
|
||||||
for (String part : split) {
|
for (String part : split) {
|
||||||
if (!part.contains(character)) {
|
if (!part.contains(character)) {
|
||||||
|
@ -20,6 +20,12 @@ public class PriceChecker implements Listener {
|
|||||||
String line = event.getSignLine(PRICE_LINE).toUpperCase();
|
String line = event.getSignLine(PRICE_LINE).toUpperCase();
|
||||||
String[] part = line.split(":");
|
String[] part = line.split(":");
|
||||||
|
|
||||||
|
System.out.println(isInvalid(part[0]) + " " + isInvalid(part[1]));
|
||||||
|
if (part.length > 1 && (isInvalid(part[0]) ^ isInvalid(part[1]))) {
|
||||||
|
line = line.replace(':', ' ');
|
||||||
|
part = new String[]{line};
|
||||||
|
}
|
||||||
|
|
||||||
if (isPrice(part[0])) {
|
if (isPrice(part[0])) {
|
||||||
line = "B " + line;
|
line = "B " + line;
|
||||||
}
|
}
|
||||||
@ -28,8 +34,6 @@ public class PriceChecker implements Listener {
|
|||||||
line += " S";
|
line += " S";
|
||||||
}
|
}
|
||||||
|
|
||||||
line = line.replace('b', 'B').replace('s', 'S');
|
|
||||||
|
|
||||||
if (line.length() > 15) {
|
if (line.length() > 15) {
|
||||||
line = line.replace(" ", "");
|
line = line.replace(" ", "");
|
||||||
}
|
}
|
||||||
@ -45,4 +49,16 @@ public class PriceChecker implements Listener {
|
|||||||
event.setOutcome(INVALID_PRICE);
|
event.setOutcome(INVALID_PRICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isInvalid(String part) {
|
||||||
|
char characters[] = {'B', 'S'};
|
||||||
|
|
||||||
|
for (char character : characters) {
|
||||||
|
if (part.contains(Character.toString(character))) {
|
||||||
|
return !PriceUtil.hasPrice(part, character);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user