Allow enum fields to be set through standalone command line

This commit is contained in:
Camotoy 2021-08-12 14:16:19 -04:00
parent b95cd8e0c1
commit e20247b6d6
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
1 changed files with 3 additions and 0 deletions

View File

@ -315,6 +315,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
* @param parentObject The object to alter
* @param value The new value of the property
*/
@SuppressWarnings("unchecked") // Required for enum usage
private static void setConfigOption(BeanPropertyDefinition property, Object parentObject, Object value) {
Object parsedValue = value;
@ -323,6 +324,8 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
parsedValue = Integer.valueOf((String) parsedValue);
} else if (boolean.class.equals(property.getRawPrimaryType())) {
parsedValue = Boolean.valueOf((String) parsedValue);
} else if (Enum.class.isAssignableFrom(property.getRawPrimaryType())) {
parsedValue = Enum.valueOf((Class<? extends Enum>) property.getRawPrimaryType(), ((String) parsedValue).toUpperCase(Locale.ROOT));
}
// Force the value to be set