8
8
import net .md_5 .bungee .chat .ComponentSerializer ;
9
9
import org .junit .jupiter .api .Test ;
10
10
11
+ import java .awt .*;
12
+
11
13
import static org .junit .jupiter .api .Assertions .assertEquals ;
12
14
13
15
public class AdvancedComponentTest {
@@ -33,4 +35,26 @@ public void testColorCodeBetweenClickEvent() {
33
35
String expectedResultJson = "{\" extra\" :[{\" strikethrough\" :true,\" color\" :\" gray\" ,\" hoverEvent\" :{\" action\" :\" show_text\" ,\" contents\" :\" \" },\" extra\" :[{\" text\" :\" Testing\" }],\" text\" :\" \" },{\" color\" :\" gray\" ,\" hoverEvent\" :{\" action\" :\" show_text\" ,\" contents\" :\" \" },\" extra\" :[{\" text\" :\" another test\" }],\" text\" :\" \" }],\" text\" :\" \" }" ;
34
36
assertEquals (expectedResultJson , ComponentSerializer .toString (components ));
35
37
}
38
+
39
+ @ Test
40
+ public void testShadowColor () {
41
+ BaseComponent root = new TextComponent ();
42
+ BaseComponent child1 = new TextComponent ("Testing" );
43
+ child1 .setColor (ChatColor .GRAY );
44
+ child1 .setStrikethrough (true );
45
+ child1 .setHoverEvent (new HoverEvent (HoverEvent .Action .SHOW_TEXT , new Text ("" )));
46
+ root .addExtra (child1 );
47
+ BaseComponent child2 = new TextComponent ("another test" );
48
+ child2 .setColor (ChatColor .GRAY );
49
+ child2 .setShadowColor (new Color (0x33 , 0x44 , 0x55 , 0x88 ));
50
+ root .addExtra (child2 );
51
+
52
+ AdvancedComponent advancedComponent = AdvancedComponent .fromBaseComponent (root );
53
+ advancedComponent .setText (advancedComponent .getTextClean ());
54
+
55
+ BaseComponent [] components = advancedComponent .toBaseComponent ();
56
+
57
+ String expectedResultJson = "{\" extra\" :[{\" strikethrough\" :true,\" color\" :\" gray\" ,\" hoverEvent\" :{\" action\" :\" show_text\" ,\" contents\" :\" \" },\" extra\" :[{\" text\" :\" Testing\" }],\" text\" :\" \" },{\" color\" :\" gray\" ,\" shadow_color\" :-2009906091,\" text\" :\" another test\" }],\" text\" :\" \" }" ;
58
+ assertEquals (expectedResultJson , ComponentSerializer .toString (components ));
59
+ }
36
60
}
0 commit comments