mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 11:18:57 +00:00
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:
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user