diff options
| author | â€huajijam <strhuaji@gmail.com> | 2019-04-30 22:52:55 +0800 |
|---|---|---|
| committer | â€huajijam <strhuaji@gmail.com> | 2019-04-30 22:52:55 +0800 |
| commit | e18a5f0e793ac8cf256d17b44910ecc0b7fdb094 (patch) | |
| tree | 2cb080a99d07318a7f86c4afe2bfbb551de2766c /src/Java/gtPlusPlus/core/util/Utils.java | |
| parent | 913bb1c0a34045b1aa11901f49107322b1c03b57 (diff) | |
| parent | 47d2b68b66fb9958b57c3ff81f1e73e8f6afd91b (diff) | |
| download | GT5-Unofficial-e18a5f0e793ac8cf256d17b44910ecc0b7fdb094.tar.gz GT5-Unofficial-e18a5f0e793ac8cf256d17b44910ecc0b7fdb094.tar.bz2 GT5-Unofficial-e18a5f0e793ac8cf256d17b44910ecc0b7fdb094.zip | |
Automatic synchronization
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/Utils.java')
| -rw-r--r-- | src/Java/gtPlusPlus/core/util/Utils.java | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 3b3ba88e88..bb1d9064e8 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -928,24 +928,19 @@ 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().equals(string) || aItem.name().toLowerCase().equals(string.toLowerCase())) { + 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."); + if (aOther != null) { + Logger.INFO("Using fallback option instead - "+aOther.name()); + } return aOther; } |
