#2725: Various improvements to chat API
* More versatile ComponentBuilder system - Allow creating a builder without an initial component - Duplicate the parts when component is created - Add getter for 'parts' * Added cursor API for more fluid component modifying * Don't legacy convert Titles on 1.11 or newer * Simplify plain and legacy text converting code - Shares the addFormat method between all superclasses - Duplicate code in TranslatableComponent moved in separate method
This commit is contained in:
@@ -51,6 +51,7 @@ import net.md_5.bungee.protocol.MinecraftDecoder;
|
||||
import net.md_5.bungee.protocol.MinecraftEncoder;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.Chat;
|
||||
import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
@@ -453,10 +454,20 @@ public final class UserConnection implements ProxiedPlayer
|
||||
// transform score components
|
||||
message = ChatComponentTransformer.getInstance().transform( this, message );
|
||||
|
||||
// Action bar doesn't display the new JSON formattings, legacy works - send it using this for now
|
||||
if ( position == ChatMessageType.ACTION_BAR )
|
||||
{
|
||||
sendMessage( position, ComponentSerializer.toString( new TextComponent( BaseComponent.toLegacyText( message ) ) ) );
|
||||
// Versions older than 1.11 cannot send the Action bar with the new JSON formattings
|
||||
// Fix by converting to a legacy message, see https://bugs.mojang.com/browse/MC-119145
|
||||
if ( ProxyServer.getInstance().getProtocolVersion() <= ProtocolConstants.MINECRAFT_1_10 )
|
||||
{
|
||||
sendMessage( position, ComponentSerializer.toString( new TextComponent( BaseComponent.toLegacyText( message ) ) ) );
|
||||
} else
|
||||
{
|
||||
net.md_5.bungee.protocol.packet.Title title = new net.md_5.bungee.protocol.packet.Title();
|
||||
title.setAction( net.md_5.bungee.protocol.packet.Title.Action.ACTIONBAR );
|
||||
title.setText( ComponentSerializer.toString( message ) );
|
||||
unsafe.sendPacket( title );
|
||||
}
|
||||
} else
|
||||
{
|
||||
sendMessage( position, ComponentSerializer.toString( message ) );
|
||||
|
Reference in New Issue
Block a user