further abstraction and implementing quality on player and server commands

Add StringParser to parse a String to other formats on the fly or on a predefined base.

Rework Builder methods for server and player commands to allow quality.

Add getServercmdsForQuality() and getPlayercmdsForQuality().

Rework loadQualityStringList() to accept the new StringParser.

Add cmdParser and loreParser to the StringParser.
This commit is contained in:
Sebi
2020-05-08 15:19:26 +02:00
parent adaeeed88c
commit aab880e437
2 changed files with 105 additions and 46 deletions
@@ -0,0 +1,33 @@
package com.dre.brewery.utility;
import com.dre.brewery.P;
public interface StringParser {
public Object parse(String line);
public static StringParser cmdParser() {
return new StringParser() {
@Override
public Object parse(String line) {
line = P.p.color(line);
int plus = 0;
if (line.startsWith("+++")) {
plus = 3;
line = line.substring(3);
} else if (line.startsWith("++")) {
plus = 2;
line = line.substring(2);
} else if (line.startsWith("+")) {
plus = 1;
line = line.substring(1);
}
if (line.startsWith("/")) {
line = line.substring(1);
}
return new Tuple<>(plus, line);
}
};
}
}