@@ -63,10 +63,10 @@ public String getString() {
6363 @ Override
6464 public Text formatValue () {
6565 MutableText text = Text .literal ("#" );
66- if (allowAlpha ()) text .append (toHex (option ().pendingValue ().getAlpha ()));
6766 text .append (Text .literal (toHex (option ().pendingValue ().getRed ())).formatted (Formatting .RED ));
6867 text .append (Text .literal (toHex (option ().pendingValue ().getGreen ())).formatted (Formatting .GREEN ));
6968 text .append (Text .literal (toHex (option ().pendingValue ().getBlue ())).formatted (Formatting .BLUE ));
69+ if (allowAlpha ()) text .append (toHex (option ().pendingValue ().getAlpha ()));
7070 return text ;
7171 }
7272
@@ -82,12 +82,16 @@ public void setFromString(String value) {
8282 if (value .startsWith ("#" ))
8383 value = value .substring (1 );
8484
85- int alpha = Integer .parseInt (value .substring (0 , 2 ), 16 );
86- int red = Integer .parseInt (allowAlpha () ? value .substring (2 , 4 ) : value .substring (0 , 2 ), 16 );
87- int green = Integer .parseInt (allowAlpha () ? value .substring (4 , 6 ) : value .substring (2 , 4 ), 16 );
88- int blue = Integer .parseInt (allowAlpha () ? value .substring (6 , 8 ) : value .substring (4 , 6 ), 16 );
85+ int red = Integer .parseInt (value .substring (0 , 2 ), 16 );
86+ int green = Integer .parseInt (value .substring (2 , 4 ), 16 );
87+ int blue = Integer .parseInt (value .substring (4 , 6 ), 16 );
8988
90- option ().requestSet (allowAlpha () ? new Color (red , green , blue , alpha ) : new Color (red , green , blue ));
89+ if (allowAlpha ()) {
90+ int alpha = Integer .parseInt (value .substring (6 , 8 ), 16 );
91+ option ().requestSet (new Color (red , green , blue , alpha ));
92+ } else {
93+ option ().requestSet (new Color (red , green , blue ));
94+ }
9195 }
9296
9397 @ Override
0 commit comments