Skip to content

Commit

Permalink
Match enums with spaces in them
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 27, 2013
1 parent 66570d1 commit 757ad83
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/net/citizensnpcs/util/Util.java
Expand Up @@ -103,12 +103,12 @@ public static EntityType matchEntityType(String toMatch) {

public static <T extends Enum<?>> T matchEnum(T[] values, String toMatch) {
T type = null;
toMatch = toMatch.toLowerCase();
for (T check : values) {
String name = check.name();
if (name.matches(toMatch) || name.equalsIgnoreCase(toMatch)
|| name.replace("_", "").equalsIgnoreCase(toMatch)
|| name.replace('_', '-').equalsIgnoreCase(toMatch)
|| name.replace('_', ' ').equalsIgnoreCase(toMatch) || name.startsWith(toMatch)) {
String name = check.name().toLowerCase();
if (name.matches(toMatch) || name.equals(toMatch) || name.replace("_", "").equals(toMatch)
|| name.replace('_', ' ').equals(toMatch) || name.replace('_', '-').equals(toMatch)
|| name.replace('_', ' ').equals(toMatch) || name.startsWith(toMatch)) {
type = check;
break;
}
Expand Down

0 comments on commit 757ad83

Please sign in to comment.