Sfoglia il codice sorgente

Custom translation key restructure

Lortseam 5 anni fa
parent
commit
f5152e1fed

+ 4 - 5
src/main/java/me/lortseam/completeconfig/ConfigManager.java

@@ -115,12 +115,11 @@ public class ConfigManager {
                     field.setAccessible(true);
                 }
                 Entry.Builder builder = Entry.Builder.create(field, container);
-                if (field.isAnnotationPresent(ConfigEntry.TranslationKey.class)) {
-                    String customTranslationKey = field.getDeclaredAnnotation(ConfigEntry.TranslationKey.class).value();
-                    if (StringUtils.isBlank(customTranslationKey)) {
-                        throw new IllegalAnnotationParameterException("Translation key for entry field " + field + " must not be blank");
+                if (field.isAnnotationPresent(ConfigEntry.class)) {
+                    String customTranslationKey = field.getDeclaredAnnotation(ConfigEntry.class).customTranslationKey();
+                    if (!StringUtils.isBlank(customTranslationKey)) {
+                        builder.setCustomTranslationKey(customTranslationKey);
                     }
-                    builder.setCustomTranslationKey(customTranslationKey);
                 }
                 if (field.isAnnotationPresent(ConfigEntry.Integer.Bounded.class)) {
                     if (field.getType() != int.class && field.getType() != Integer.class) {

+ 1 - 7
src/main/java/me/lortseam/completeconfig/api/ConfigEntry.java

@@ -12,13 +12,7 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 public @interface ConfigEntry {
 
-    @Target(ElementType.FIELD)
-    @Retention(RetentionPolicy.RUNTIME)
-    @interface TranslationKey {
-
-        String value();
-
-    }
+    String customTranslationKey() default "";
 
     @NoArgsConstructor(access = AccessLevel.PRIVATE)
     class Integer {