소스 검색

Moved TextColor serializer

Lortseam 4 년 전
부모
커밋
1bde06eea6
2개의 변경된 파일17개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 1
      src/main/java/me/lortseam/completeconfig/ModController.java
  2. 16 9
      src/main/java/me/lortseam/completeconfig/data/ColorEntry.java

+ 1 - 1
src/main/java/me/lortseam/completeconfig/ModController.java

@@ -18,7 +18,7 @@ public final class ModController {
 
     private static final Map<String, ModController> controllers = new HashMap<>();
     private static final TypeSerializerCollection GLOBAL_TYPE_SERIALIZERS = TypeSerializerCollection.builder()
-            .registerExact(ColorEntry.TEXT_COLOR_SERIALIZER)
+            .registerExact(ColorEntry.Serializers.TEXT_COLOR)
             .build();
 
     /**

+ 16 - 9
src/main/java/me/lortseam/completeconfig/data/ColorEntry.java

@@ -1,6 +1,8 @@
 package me.lortseam.completeconfig.data;
 
+import lombok.AccessLevel;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import me.lortseam.completeconfig.api.ConfigEntryContainer;
 import me.lortseam.completeconfig.data.gui.TranslationIdentifier;
 import net.minecraft.text.TextColor;
@@ -12,15 +14,6 @@ import java.lang.reflect.Field;
 
 public class ColorEntry<T> extends Entry<T> {
 
-    public static final ScalarSerializer<TextColor> TEXT_COLOR_SERIALIZER = TypeSerializer.of(TextColor.class, (item, typeSupported) -> {
-        return item.getRgb();
-    }, value -> {
-        if (value instanceof Integer) {
-            return TextColor.fromRgb((int) value);
-        }
-        throw new CoercionFailedException(value, "TextColor");
-    });
-
     @Getter
     private final boolean alphaMode;
 
@@ -29,4 +22,18 @@ public class ColorEntry<T> extends Entry<T> {
         this.alphaMode = alphaMode;
     }
 
+    @NoArgsConstructor(access = AccessLevel.PRIVATE)
+    public static final class Serializers {
+
+        public static final ScalarSerializer<TextColor> TEXT_COLOR = TypeSerializer.of(TextColor.class, (item, typeSupported) -> {
+            return item.getRgb();
+        }, value -> {
+            if (value instanceof Integer) {
+                return TextColor.fromRgb((int) value);
+            }
+            throw new CoercionFailedException(value, "TextColor");
+        });
+
+    }
+
 }