33import net .md_5 .bungee .api .ChatColor ;
44import net .md_5 .bungee .api .chat .ComponentBuilder ;
55import net .md_5 .bungee .api .chat .TextComponent ;
6+ import org .jetbrains .annotations .NotNull ;
67
78public class ColorTranslator {
89
@@ -12,7 +13,7 @@ public class ColorTranslator {
1213 * @param text The string of text to apply color/effects to
1314 * @return Returns a string of text with color/effects applied
1415 */
15- public static String translateColorCodes (String text ){
16+ public static String translateColorCodes (@ NotNull String text ){
1617
1718 String [] texts = text .split (String .format (WITH_DELIMITER , "&" ));
1819
@@ -23,7 +24,7 @@ public static String translateColorCodes(String text){
2324 //get the next string
2425 i ++;
2526 if (texts [i ].charAt (0 ) == '#' ){
26- finalText .append (ChatColor .of (texts [i ].substring (0 , 7 )) + texts [i ].substring (7 ));
27+ finalText .append (ChatColor .of (texts [i ].substring (0 , 7 ))). append ( texts [i ].substring (7 ));
2728 }else {
2829 finalText .append (ChatColor .translateAlternateColorCodes ('&' , "&" + texts [i ]));
2930 }
@@ -39,7 +40,7 @@ public static String translateColorCodes(String text){
3940 * @param text The text with color codes that you want to turn into a TextComponent
4041 * @return the TextComponent with hex colors and regular colors
4142 */
42- public static TextComponent translateColorCodesToTextComponent (String text ){
43+ public static TextComponent translateColorCodesToTextComponent (@ NotNull String text ){
4344
4445 String [] texts = text .split (String .format (WITH_DELIMITER , "&" ));
4546
@@ -53,7 +54,6 @@ public static TextComponent translateColorCodesToTextComponent(String text){
5354 if (texts [i ].charAt (0 ) == '#' ){
5455 subComponent .setText (texts [i ].substring (7 ));
5556 subComponent .setColor (net .md_5 .bungee .api .ChatColor .of (texts [i ].substring (0 , 7 )));
56- builder .append (subComponent );
5757 }else {
5858 if (texts [i ].length () > 1 ){
5959 subComponent .setText (texts [i ].substring (1 ));
@@ -130,8 +130,8 @@ public static TextComponent translateColorCodesToTextComponent(String text){
130130 break ;
131131 }
132132
133- builder .append (subComponent );
134133 }
134+ builder .append (subComponent );
135135 }else {
136136 builder .append (texts [i ]);
137137 }
@@ -140,6 +140,4 @@ public static TextComponent translateColorCodesToTextComponent(String text){
140140 return new TextComponent (builder .create ());
141141
142142 }
143-
144-
145143}
0 commit comments