diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r-- | src/Java/gtPlusPlus/core/util/Utils.java | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 3b3ba88e88..919d2f13f3 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -928,24 +928,17 @@ public class Utils { return false; } - public static ItemList getValueOfItemList(String string, ItemList aOther) { - try { - Method method = ItemList.class.getDeclaredMethod("values"); - Object obj = method.invoke(null); - String y = Arrays.toString((Object[]) obj); - String[] aCurrentItemsInList = y.split(","); - boolean found = false; - for (String g : aCurrentItemsInList) { - if (g.equals(string)) { - found = true; - break; + public static ItemList getValueOfItemList(String string, ItemList aOther) { + ItemList[] aListValues = ItemList.class.getEnumConstants(); + for (ItemList aItem : aListValues) { + if (aItem != null) { + if (aItem.name().toLowerCase().equals(string)) { + return aItem; } } - if (found) { - return ItemList.valueOf(string); - } } - catch (Throwable t) {} + Logger.INFO("Tried to obtain '"+string+"' from the GT ItemList, however it does not exist."); + Logger.INFO("Using fallback option instead - "+aOther.name()); return aOther; } |