From 757ad8313c8825905d47593a98e6f70884cb8863 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sat, 27 Jul 2013 14:23:59 +0800 Subject: [PATCH] Match enums with spaces in them --- src/main/java/net/citizensnpcs/util/Util.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/citizensnpcs/util/Util.java b/src/main/java/net/citizensnpcs/util/Util.java index b4ff9271c..2b1515e43 100644 --- a/src/main/java/net/citizensnpcs/util/Util.java +++ b/src/main/java/net/citizensnpcs/util/Util.java @@ -103,12 +103,12 @@ public static EntityType matchEntityType(String toMatch) { public static > 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; }