mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 11:18:57 +00:00
Some changes to the Quality StringParser
This commit is contained in:
@@ -2,57 +2,38 @@ package com.dre.brewery.utility;
|
||||
|
||||
import com.dre.brewery.P;
|
||||
|
||||
public interface StringParser {
|
||||
public class StringParser {
|
||||
|
||||
public Object parse(String line);
|
||||
|
||||
public static StringParser cmdParser = 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);
|
||||
}
|
||||
if (line.startsWith("/")) {
|
||||
line = line.substring(1);
|
||||
}
|
||||
return new Tuple<Integer,String>(plus, line);
|
||||
public static Tuple<Integer, String> parseQuality(String line, ParseType type) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
public static StringParser loreParser = 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);
|
||||
}
|
||||
if (!line.startsWith("§")) {
|
||||
line = "§9" + line;
|
||||
}
|
||||
return new Tuple<Integer,String>(plus, line);
|
||||
if (line.startsWith(" ")) {
|
||||
line = line.substring(1);
|
||||
}
|
||||
};
|
||||
|
||||
if (type == ParseType.CMD && line.startsWith("/")) {
|
||||
line = line.substring(1);
|
||||
}
|
||||
|
||||
if (type == ParseType.LORE && !line.startsWith("§")) {
|
||||
line = "§9" + line;
|
||||
}
|
||||
return new Tuple<Integer,String>(plus, line);
|
||||
}
|
||||
|
||||
public enum ParseType {
|
||||
LORE,
|
||||
CMD,
|
||||
OTHER
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user