question: private void printRainbowUser ( User user , String userName , boolean action , SpecialColor type , String id ) { SimpleAttributeSet userStyle = new SimpleAttributeSet ( styles . nick ( ) ) ; userStyle . addAttribute ( Attribute . IS_USER_MESSAGE , true ) ; userStyle . addAttribute ( Attribute . USER , user ) ; if ( id != null ) { userStyle . addAttribute ( Attribute . ID , id ) ; } int length = userName . length ( ) ; if ( action ) { print ( "* " , styles . nick ( ) ) ; } for ( int i = 0 ; i < length ; i ++ ) { Color c ; if ( type == SpecialColor . RAINBOW ) { c = makeRainbowColor ( i , length ) ; } else { c = makeGoldColor ( i , length ) ; } StyleConstants . setForeground ( userStyle , c ) ; print ( userName . substring ( i , i + 1 ) , userStyle ) ; } }
target:  Output the username in rainbow colors. This means each character has to be output on it's own, while changing the color. One style with the appropriate User metadata is used and the color changed. Prints the rest (what doesn't belong to the nick itself) based on the default user style.