@@ -45,46 +45,45 @@ private SettingUtils() {}
4545 public static <T > OptionInstance <T > getOptionForSetting (ISetting <T > setting ) {
4646 OptionInstance <T > option = null ;
4747 String translationKey = "anvilclient.feature." + setting .getKey ();
48- if (setting instanceof BooleanSetting booleanSetting ) {
49- option =
50- (OptionInstance <T >)
51- OptionInstance .createBoolean (
52- translationKey , booleanSetting .getValue (), booleanSetting ::setValue );
53-
54- } else if (setting instanceof EnumSetting <?> enumSetting ) {
55- option = (OptionInstance <T >) optionInstanceForEnum (enumSetting , translationKey );
56-
57- } else if (setting instanceof IntegerSetting integerSetting ) {
58- option =
59- (OptionInstance <T >)
60- new OptionInstance <Integer >(
61- translationKey ,
62- OptionInstance .noTooltip (),
63- (component , integer ) ->
64- Options .genericValueLabel (component , integerSetting .getIntValue ()),
65- new OptionInstance .IntRange (
66- integerSetting .getMinValue (), integerSetting .getMaxValue ()),
67- integerSetting .getValue (),
68- integerSetting ::setValue );
69-
70- } else if (setting instanceof DoubleSetting doubleSetting ) {
71- option =
72- (OptionInstance <T >)
73- new OptionInstance <Double >(
74- translationKey ,
75- OptionInstance .noTooltip (),
76- (component , doubleValue ) ->
77- Options .genericValueLabel (
78- component ,
79- Component .literal (
80- MathUtils .formatDouble (
81- doubleValue , doubleSetting .getDecimalCount ()))),
82- new DoubleRange (
83- doubleSetting .getMinValue (),
84- doubleSetting .getMaxValue (),
85- doubleSetting .getDecimalCount ()),
86- doubleSetting .getValue (),
87- doubleSetting ::setValue );
48+ switch (setting ) {
49+ case BooleanSetting booleanSetting ->
50+ option =
51+ (OptionInstance <T >)
52+ OptionInstance .createBoolean (
53+ translationKey , booleanSetting .getValue (), booleanSetting ::setValue );
54+ case EnumSetting <?> enumSetting ->
55+ option = (OptionInstance <T >) optionInstanceForEnum (enumSetting , translationKey );
56+ case IntegerSetting integerSetting ->
57+ option =
58+ (OptionInstance <T >)
59+ new OptionInstance <Integer >(
60+ translationKey ,
61+ OptionInstance .noTooltip (),
62+ (component , integer ) ->
63+ Options .genericValueLabel (component , integerSetting .getIntValue ()),
64+ new OptionInstance .IntRange (
65+ integerSetting .getMinValue (), integerSetting .getMaxValue ()),
66+ integerSetting .getValue (),
67+ integerSetting ::setValue );
68+ case DoubleSetting doubleSetting ->
69+ option =
70+ (OptionInstance <T >)
71+ new OptionInstance <Double >(
72+ translationKey ,
73+ OptionInstance .noTooltip (),
74+ (component , doubleValue ) ->
75+ Options .genericValueLabel (
76+ component ,
77+ Component .literal (
78+ MathUtils .formatDouble (
79+ doubleValue , doubleSetting .getDecimalCount ()))),
80+ new DoubleRange (
81+ doubleSetting .getMinValue (),
82+ doubleSetting .getMaxValue (),
83+ doubleSetting .getDecimalCount ()),
84+ doubleSetting .getValue (),
85+ doubleSetting ::setValue );
86+ default -> {}
8887 }
8988 return option ;
9089 }
0 commit comments