@@ -29,50 +29,39 @@ const ChatChatVentureChatConverter = new Converter<VentureChatConfig, { format:
29
29
parts : [ ]
30
30
} ;
31
31
32
- ( [ "venturechat_channel_prefix" , "vault_prefix" , "player_displayname" ] ) . forEach ( key => {
33
- [ vcFormat . json_attributes . venturechat_channel_prefix , vcFormat . json_attributes . vault_prefix , vcFormat . json_attributes . player_displayname ]
34
- const part = `%${ key } %` ;
35
-
36
- let section : VentureChatJsonComponent ;
37
- switch ( key ) {
38
- case 'venturechat_channel_prefix' :
39
- section = vcFormat . json_attributes . venturechat_channel_prefix
40
- break ;
41
- case 'vault_prefix' :
42
- section = vcFormat . json_attributes . vault_prefix
43
- break ;
44
- default :
45
- section = vcFormat . json_attributes . player_displayname
46
- break ;
47
- }
48
-
49
- let formattedSection = part ;
50
- switch ( section . click_action ) {
51
- case "suggest_command" : {
52
- formattedSection = "<click:suggest_command:'" + section . click_text + "'>" + formattedSection + "</click>" ;
53
- break ;
32
+ if ( vcFormat . json_attributes ) {
33
+ const innerFormat = vcFormat . json_attributes ;
34
+ Object . keys ( innerFormat ) . forEach ( key => {
35
+ const part = `%${ key } %` ;
36
+ const section = innerFormat [ key ] ;
37
+ let formattedSection = part ;
38
+ switch ( section . click_action ) {
39
+ case "suggest_command" : {
40
+ formattedSection = "<click:suggest_command:'" + section . click_text + "'>" + formattedSection + "</click>" ;
41
+ break ;
42
+ }
43
+ case "run_command" : {
44
+ formattedSection = "<click:run_command:'" + section . click_text + "'>" + formattedSection + "</click>" ;
45
+ break ;
46
+ }
47
+ case "open_url" : {
48
+ formattedSection = "<click:open_url:'" + section . click_text + "'>" + formattedSection + "</click>" ;
49
+ break ;
50
+ }
54
51
}
55
- case "run_command" : {
56
- formattedSection = "<click:run_command:'" + section . click_text + "'>" + formattedSection + "</click>" ;
57
- break ;
52
+ let hover = section . hover_text . filter ( s => s && s !== "" )
53
+ if ( hover && hover . length > 0 ) {
54
+ formattedSection = "<hover:show_text:'" + hover . join ( "<newline>" ) + "'>" + formattedSection + "</hover>" ;
58
55
}
59
- case "open_url" : {
60
- formattedSection = "<click:open_url:'" + section . click_text + "'>" + formattedSection + "</click>" ;
61
- break ;
62
- }
63
- }
64
- let hover = section . hover_text . filter ( s => s && s !== "" )
65
- if ( hover && hover . length > 0 ) {
66
- formattedSection = "<hover:show_text:'" + hover . join ( "<newline>" ) + "'>" + formattedSection + "</hover>" ;
67
- }
68
56
69
- if ( formattedSection !== "" ) {
70
- ccFormat . parts . push ( MiniMessage ( formattedSection ) ) ;
71
- }
72
- } )
73
- ccFormat . parts . push ( "<message>" )
74
- chatchatFormatsConfig . formats [ name ] = ccFormat ;
75
- } )
57
+ if ( formattedSection !== "" ) {
58
+ ccFormat . parts . push ( MiniMessage ( formattedSection ) ) ;
59
+ }
60
+ } )
61
+ ccFormat . parts . push ( "<message>" )
62
+ chatchatFormatsConfig . formats [ name ] = ccFormat ;
63
+ }
64
+ } ) ;
76
65
}
77
66
78
67
0 commit comments