Fix enum MixinEnvironment.Option parsing always using the default (#157)

* Fix enum MixinEnvironment.Option parsing always using the default

* Incorporate Chocohead's suggestion
This commit is contained in:
Player authored and GitHub committed 2025-07-27 14:09:02 -04:00
1 parent da718519e2
commit da648eae8d
1 file changed
+1 -2
@@ -625,11 +625,10 @@ public final class MixinEnvironment implements ITokenProvider {
? System.getProperty(this.property, this.defaultValue) : this.defaultValue;
}
@SuppressWarnings("unchecked")
<E extends Enum<E>> E getEnumValue(E defaultValue) {
String value = System.getProperty(this.property, defaultValue.name());
try {
return (E)Enum.valueOf(defaultValue.getClass(), value.toUpperCase(Locale.ROOT));
return Enum.valueOf(defaultValue.getDeclaringClass(), value.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException ex) {
return defaultValue;
}