#1765: Fix ServerInfo.ping to handle chat components.
This commit is contained in:
parent
dd66e3068a
commit
7926230682
@ -5,8 +5,11 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.Util;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* Represents the standard list data returned by opening a server in the
|
||||
@ -73,7 +76,8 @@ public class ServerPing
|
||||
return uniqueId.toString().replaceAll( "-", "" );
|
||||
}
|
||||
}
|
||||
private String description;
|
||||
|
||||
private BaseComponent description;
|
||||
private Favicon favicon;
|
||||
|
||||
@Data
|
||||
@ -100,7 +104,13 @@ public class ServerPing
|
||||
@Deprecated
|
||||
public ServerPing(Protocol version, Players players, String description, String favicon)
|
||||
{
|
||||
this( version, players, description, favicon == null ? null : Favicon.create( favicon ) );
|
||||
this( version, players, new TextComponent( TextComponent.fromLegacyText(description) ), favicon == null ? null : Favicon.create( favicon ) );
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ServerPing(Protocol version, Players players, String description, Favicon favicon)
|
||||
{
|
||||
this( version, players, new TextComponent( TextComponent.fromLegacyText(description) ), favicon );
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -124,4 +134,18 @@ public class ServerPing
|
||||
{
|
||||
this.favicon = favicon;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDescription(String description) {
|
||||
this.description = new TextComponent( TextComponent.fromLegacyText( description ) );
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getDescription() {
|
||||
return BaseComponent.toLegacyText( description );
|
||||
}
|
||||
|
||||
public BaseComponent getDescriptionComponent() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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>()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user