@@ -35,7 +35,7 @@ public class ConfigurationManager {
3535 * @param config The class to register.
3636 */
3737 public static void registerConfig (Class <?> config ) throws IllegalAccessException {
38- val cfg = Optional .of (config .getAnnotation (Config .class )).orElseThrow (() -> new IllegalArgumentException ("Class " + config .getName () + " does not have a @Config annotation!" ));
38+ val cfg = Optional .ofNullable (config .getAnnotation (Config .class )).orElseThrow (() -> new IllegalArgumentException ("Class " + config .getName () + " does not have a @Config annotation!" ));
3939 val cfgSet = configs .computeIfAbsent (cfg .modid (), (ignored ) -> new HashSet <>());
4040 cfgSet .add (config );
4141 processConfig (config );
@@ -82,24 +82,24 @@ private static void processConfig(Class<?> configClass) throws IllegalAccessExce
8282 for (val field : configClass .getDeclaredFields ()) {
8383 if (field .getAnnotation (Config .Ignore .class ) != null ) continue ;
8484 field .setAccessible (true );
85- val comment = Optional .of (field .getAnnotation (Config .Comment .class )).map (Config .Comment ::value ).map ((lines ) -> String .join ("\n " , lines )).orElse ("" );
86- val name = Optional .of (field .getAnnotation (Config .Name .class )).map (Config .Name ::value ).orElse (field .getName ());
87- val langKey = Optional .of (field .getAnnotation (Config .LangKey .class )).map (Config .LangKey ::value ).orElse (name );
85+ val comment = Optional .ofNullable (field .getAnnotation (Config .Comment .class )).map (Config .Comment ::value ).map ((lines ) -> String .join ("\n " , lines )).orElse ("" );
86+ val name = Optional .ofNullable (field .getAnnotation (Config .Name .class )).map (Config .Name ::value ).orElse (field .getName ());
87+ val langKey = Optional .ofNullable (field .getAnnotation (Config .LangKey .class )).map (Config .LangKey ::value ).orElse (name );
8888 var boxed = false ;
8989 Property prop = cat .get (name );
9090 prop .comment = comment ;
9191 prop .setLanguageKey (langKey );
9292 if ((boxed = field .getType ().equals (Integer .class )) || field .getType ().equals (int .class )) {
93- val range = Optional .of (field .getAnnotation (Config .RangeInt .class ));
93+ val range = Optional .ofNullable (field .getAnnotation (Config .RangeInt .class ));
9494 prop .setMinValue (range .map (Config .RangeInt ::min ).orElse (Integer .MIN_VALUE ));
9595 prop .setMaxValue (range .map (Config .RangeInt ::max ).orElse (Integer .MAX_VALUE ));
96- prop .setDefaultValue (Optional .of (field .getAnnotation (Config .DefaultInt .class )).map (Config .DefaultInt ::value ).orElse (boxed ? (Integer )field .get (null ) : field .getInt (null )));
96+ prop .setDefaultValue (Optional .ofNullable (field .getAnnotation (Config .DefaultInt .class )).map (Config .DefaultInt ::value ).orElse (boxed ? (Integer )field .get (null ) : field .getInt (null )));
9797 field .setInt (null , prop .getInt ());
9898 } else if ((boxed = field .getType ().equals (Double .class )) || field .getType ().equals (double .class )) {
99- val range = Optional .of (field .getAnnotation (Config .RangeDouble .class ));
99+ val range = Optional .ofNullable (field .getAnnotation (Config .RangeDouble .class ));
100100 prop .setMinValue (range .map (Config .RangeDouble ::min ).orElse (Double .MIN_VALUE ));
101101 prop .setMaxValue (range .map (Config .RangeDouble ::max ).orElse (Double .MAX_VALUE ));
102- prop .setDefaultValue (Optional .of (field .getAnnotation (Config .DefaultDouble .class )).map (Config .DefaultDouble ::value ).orElse (boxed ? (Double ) field .get (null ) : field .getDouble (null )));
102+ prop .setDefaultValue (Optional .ofNullable (field .getAnnotation (Config .DefaultDouble .class )).map (Config .DefaultDouble ::value ).orElse (boxed ? (Double ) field .get (null ) : field .getDouble (null )));
103103 field .setDouble (null , prop .getDouble ());
104104 } else if ((boxed = field .getType ().equals (Boolean .class )) || field .getType ().equals (boolean .class )) {
105105 prop .setDefaultValue (boxed ? (Boolean )field .get (null ) : field .getBoolean (null ));
0 commit comments