Fix issue with items that have a single character in name (Fixes #339)
This commit is contained in:
parent
6a34054bc7
commit
5bc23214e0
|
@ -132,7 +132,7 @@ public class MaterialUtil {
|
||||||
* @return Material found
|
* @return Material found
|
||||||
*/
|
*/
|
||||||
public static Material getMaterial(String name) {
|
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);
|
Material material = MATERIAL_CACHE.get(formatted);
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
|
@ -402,7 +402,7 @@ public class MaterialUtil {
|
||||||
return E.valueOf(values[0].getDeclaringClass(), name.toUpperCase(Locale.ROOT));
|
return E.valueOf(values[0].getDeclaringClass(), name.toUpperCase(Locale.ROOT));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
E currentEnum = null;
|
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;
|
int length = Short.MAX_VALUE;
|
||||||
for (E e : values) {
|
for (E e : values) {
|
||||||
String enumName = e.name();
|
String enumName = e.name();
|
||||||
|
|
Loading…
Reference in New Issue