@@ -343,15 +343,35 @@ private static String convertToJsonColors(String s, String extensions) {
343343 underlined = false ;
344344 }
345345 if (bold )
346- modifier += ",\" bold\" :\" true\" " ;
346+ if (VersionHandler .isAtLeast_1_20_4 ()) {
347+ modifier += ",\" bold\" :true" ;
348+ } else {
349+ modifier += ",\" bold\" :\" true\" " ;
350+ }
347351 if (obfuscated )
348- modifier += ",\" obfuscated\" :\" true\" " ;
352+ if (VersionHandler .isAtLeast_1_20_4 ()) {
353+ modifier += ",\" obfuscated\" :true" ;
354+ } else {
355+ modifier += ",\" obfuscated\" :\" true\" " ;
356+ }
349357 if (italic )
350- modifier += ",\" italic\" :\" true\" " ;
358+ if (VersionHandler .isAtLeast_1_20_4 ()) {
359+ modifier += ",\" italic\" :true" ;
360+ } else {
361+ modifier += ",\" italic\" :\" true\" " ;
362+ }
351363 if (underlined )
352- modifier += ",\" underlined\" :\" true\" " ;
364+ if (VersionHandler .isAtLeast_1_20_4 ()) {
365+ modifier += ",\" underlined\" :true" ;
366+ } else {
367+ modifier += ",\" underlined\" :\" true\" " ;
368+ }
353369 if (strikethrough )
354- modifier += ",\" strikethrough\" :\" true\" " ;
370+ if (VersionHandler .isAtLeast_1_20_4 ()) {
371+ modifier += ",\" strikethrough\" :true" ;
372+ } else {
373+ modifier += ",\" strikethrough\" :\" true\" " ;
374+ }
355375 remaining = remaining .substring (colorLength );
356376 colorLength = LEGACY_COLOR_CODE_LENGTH ;
357377 indexNextColor = remaining .indexOf (BUKKIT_COLOR_CODE_PREFIX );
@@ -448,16 +468,20 @@ public static String formatModerationGUI(String json, Player player, String send
448468
449469 public static PacketContainer createPacketPlayOutChat (String json ) {
450470 final PacketContainer container ;
451- if (VersionHandler .isAbove_1_19 ()) {
471+ if (VersionHandler .isAtLeast_1_20_4 ()) { // 1.20.4+
472+ container = new PacketContainer (PacketType .Play .Server .SYSTEM_CHAT );
473+ container .getChatComponents ().write (0 , WrappedChatComponent .fromJson (json ));
474+ container .getBooleans ().write (0 , false );
475+ } else if (VersionHandler .isAbove_1_19 ()) { // 1.19.1 -> 1.20.3
452476 container = new PacketContainer (PacketType .Play .Server .SYSTEM_CHAT );
453477 container .getStrings ().write (0 , json );
454478 container .getBooleans ().write (0 , false );
455- } else if (VersionHandler .isUnder_1_19 ()) {
479+ } else if (VersionHandler .isUnder_1_19 ()) { // 1.7 -> 1.19
456480 WrappedChatComponent component = WrappedChatComponent .fromJson (json );
457481 container = new PacketContainer (PacketType .Play .Server .CHAT );
458482 container .getModifier ().writeDefaults ();
459483 container .getChatComponents ().write (0 , component );
460- } else {
484+ } else { // 1.19
461485 container = new PacketContainer (PacketType .Play .Server .SYSTEM_CHAT );
462486 container .getStrings ().write (0 , json );
463487 container .getIntegers ().write (0 , 1 );
@@ -467,15 +491,19 @@ public static PacketContainer createPacketPlayOutChat(String json) {
467491
468492 public static PacketContainer createPacketPlayOutChat (WrappedChatComponent component ) {
469493 final PacketContainer container ;
470- if (VersionHandler .isAbove_1_19 ()) {
494+ if (VersionHandler .isAtLeast_1_20_4 ()) { // 1.20.4+
495+ container = new PacketContainer (PacketType .Play .Server .SYSTEM_CHAT );
496+ container .getChatComponents ().write (0 , component );
497+ container .getBooleans ().write (0 , false );
498+ } else if (VersionHandler .isAbove_1_19 ()) { // 1.19.1 -> 1.20.3
471499 container = new PacketContainer (PacketType .Play .Server .SYSTEM_CHAT );
472500 container .getStrings ().write (0 , component .getJson ());
473501 container .getBooleans ().write (0 , false );
474- } else if (VersionHandler .isUnder_1_19 ()) {
502+ } else if (VersionHandler .isUnder_1_19 ()) { // 1.7 -> 1.19
475503 container = new PacketContainer (PacketType .Play .Server .CHAT );
476504 container .getModifier ().writeDefaults ();
477505 container .getChatComponents ().write (0 , component );
478- } else {
506+ } else { // 1.19
479507 container = new PacketContainer (PacketType .Play .Server .SYSTEM_CHAT );
480508 container .getStrings ().write (0 , component .getJson ());
481509 container .getIntegers ().write (0 , 1 );
0 commit comments