Browse Source

Fix fetching of primitive types

Lortseam 3 năm trước cách đây
mục cha
commit
0099b58b7a

+ 3 - 2
lib/src/main/java/me/lortseam/completeconfig/data/Entry.java

@@ -7,10 +7,10 @@ import lombok.extern.log4j.Log4j2;
 import me.lortseam.completeconfig.CompleteConfig;
 import me.lortseam.completeconfig.api.ConfigContainer;
 import me.lortseam.completeconfig.api.ConfigEntry;
+import me.lortseam.completeconfig.data.structure.Identifiable;
 import me.lortseam.completeconfig.data.structure.StructurePart;
 import me.lortseam.completeconfig.data.structure.client.TooltipSupplier;
 import me.lortseam.completeconfig.data.structure.client.Translatable;
-import me.lortseam.completeconfig.data.structure.Identifiable;
 import me.lortseam.completeconfig.data.transform.Transformation;
 import me.lortseam.completeconfig.data.transform.Transformer;
 import me.lortseam.completeconfig.exception.IllegalAnnotationParameterException;
@@ -179,7 +179,8 @@ public class Entry<T> implements StructurePart, Identifiable, Translatable, Tool
     @Override
     public void fetch(CommentedConfigurationNode node) {
         try {
-            node.set(getType(), getValue());
+            // Need to box the type here as getValue returns the boxed value
+            node.set(ReflectionUtils.boxType(getType()), getValue());
             if (comment != null) {
                 node.comment(comment);
             }

+ 4 - 0
lib/src/main/java/me/lortseam/completeconfig/util/ReflectionUtils.java

@@ -43,4 +43,8 @@ public final class ReflectionUtils {
         return Optional.of(method);
     }
 
+    public static Type boxType(Type type) {
+        return GenericTypeReflector.box(type);
+    }
+
 }