mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-15 12:41:20 +01:00
Match enums with spaces in them
This commit is contained in:
parent
383602ba83
commit
29ba808908
@ -103,12 +103,12 @@ public class Util {
|
|||||||
|
|
||||||
public static <T extends Enum<?>> T matchEnum(T[] values, String toMatch) {
|
public static <T extends Enum<?>> T matchEnum(T[] values, String toMatch) {
|
||||||
T type = null;
|
T type = null;
|
||||||
|
toMatch = toMatch.toLowerCase();
|
||||||
for (T check : values) {
|
for (T check : values) {
|
||||||
String name = check.name();
|
String name = check.name().toLowerCase();
|
||||||
if (name.matches(toMatch) || name.equalsIgnoreCase(toMatch)
|
if (name.matches(toMatch) || name.equals(toMatch) || name.replace("_", "").equals(toMatch)
|
||||||
|| name.replace("_", "").equalsIgnoreCase(toMatch)
|
|| name.replace('_', ' ').equals(toMatch) || name.replace('_', '-').equals(toMatch)
|
||||||
|| name.replace('_', '-').equalsIgnoreCase(toMatch)
|
|| name.replace('_', ' ').equals(toMatch) || name.startsWith(toMatch)) {
|
||||||
|| name.replace('_', ' ').equalsIgnoreCase(toMatch) || name.startsWith(toMatch)) {
|
|
||||||
type = check;
|
type = check;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user