From e20247b6d677426ce479976b59c898077c81b731 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Thu, 12 Aug 2021 14:16:19 -0400 Subject: [PATCH] Allow enum fields to be set through standalone command line --- .../platform/standalone/GeyserStandaloneBootstrap.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java index 1a25d2792..f875127cc 100644 --- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java @@ -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) property.getRawPrimaryType(), ((String) parsedValue).toUpperCase(Locale.ROOT)); } // Force the value to be set