ソースを参照

Fix crash when no deserializer is present

Lortseam 4 年 前
コミット
392eac3aaf
1 ファイル変更10 行追加1 行削除
  1. 10 1
      lib/src/main/java/me/lortseam/completeconfig/data/Entry.java

+ 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> {