Fix issue with items that have a single character in name (Fixes #339)

This commit is contained in:
Phoenix616 2020-07-08 21:40:06 +01:00
parent 6a34054bc7
commit 5bc23214e0
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 2 additions and 2 deletions

View File

@ -132,7 +132,7 @@ public class MaterialUtil {
* @return Material found
*/
public static Material getMaterial(String name) {
String formatted = name.replaceAll("([a-z])([A-Z1-9])", "$1_$2").replace(' ', '_').toUpperCase(Locale.ROOT);
String formatted = name.replaceAll("(?<!^)([A-Z1-9])", "_$1").replace(' ', '_').toUpperCase(Locale.ROOT);
Material material = MATERIAL_CACHE.get(formatted);
if (material != null) {
@ -402,7 +402,7 @@ public class MaterialUtil {
return E.valueOf(values[0].getDeclaringClass(), name.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException exception) {
E currentEnum = null;
String[] typeParts = name.replaceAll("([a-z])([A-Z1-9])", "$1_$2").toUpperCase(Locale.ROOT).split("[ _]");
String[] typeParts = name.replaceAll("(?<!^)([A-Z1-9])", "_$1").toUpperCase(Locale.ROOT).split("[ _]");
int length = Short.MAX_VALUE;
for (E e : values) {
String enumName = e.name();