Răsfoiți Sursa

Fix crash when no deserializer is present

Lortseam 4 ani în urmă
părinte
comite
392eac3aaf

+ 10 - 1
lib/src/main/java/me/lortseam/completeconfig/data/Entry.java

@@ -166,7 +166,11 @@ public class Entry<T> implements DataPart, Identifiable, Translatable, TooltipSu
     @Override
     public void apply(CommentedConfigurationNode node) {
         try {
-            setValue((T) node.get(getType()));
+            T value = (T) node.get(getType());
+            if (value == null) {
+                throw new SerializationException(node, getType(), "Unable to deserialize value of this type");
+            }
+            setValue(value);
         } catch (SerializationException e) {
             logger.error("Failed to apply value to entry", e);
         }
@@ -184,6 +188,11 @@ public class Entry<T> implements DataPart, Identifiable, Translatable, TooltipSu
         }
     }
 
+    @Override
+    public String toString() {
+        return origin.getField().toString();
+    }
+
     @FunctionalInterface
     private interface Setter<T> {