#1765: Fix ServerInfo.ping to handle chat components.

This commit is contained in:
Thinkofdeath
2016-03-01 12:37:45 +11:00
committed by md_5
parent dd66e3068a
commit 7926230682
3 changed files with 34 additions and 3 deletions

View File

@@ -11,6 +11,9 @@ import com.google.gson.GsonBuilder;
import net.md_5.bungee.api.Favicon;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.Title;
import net.md_5.bungee.api.chat.TranslatableComponent;
import net.md_5.bungee.chat.TextComponentSerializer;
import net.md_5.bungee.chat.TranslatableComponentSerializer;
import net.md_5.bungee.module.ModuleManager;
import com.google.common.io.ByteStreams;
import net.md_5.bungee.api.chat.BaseComponent;
@@ -140,6 +143,9 @@ public class BungeeCord extends ProxyServer
@Getter
private final Logger logger;
public final Gson gson = new GsonBuilder()
.registerTypeAdapter( BaseComponent.class, new ComponentSerializer() )
.registerTypeAdapter( TextComponent.class, new TextComponentSerializer() )
.registerTypeAdapter( TranslatableComponent.class, new TranslatableComponentSerializer() )
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer() )
.registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
@Getter

View File

@@ -142,7 +142,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
final boolean v1_5 = ping.isV1_5();
ServerPing legacy = new ServerPing( new ServerPing.Protocol( bungee.getName() + " " + bungee.getGameVersion(), bungee.getProtocolVersion() ),
new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount(), null ), listener.getMotd(), (Favicon) null );
new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount(), null ),
new TextComponent( TextComponent.fromLegacyText( listener.getMotd() ) ), (Favicon) null );
Callback<ProxyPingEvent> callback = new Callback<ProxyPingEvent>()
{