更改 BungeeCord 中的 Motd 和 ServerPing

Change the Motd and ServerPing in BungeeCord

import java.util.UUID;

import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.event.ProxyPingEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;

public class MOTD implements Listener {
    
    @EventHandler
    
    public void onPing(ProxyPingEvent e) {
        
        ServerPing ping = e.getResponse();
        ServerPing.Players player = ping.getPlayers();
        ServerPing.Protocol vers = ping.getVersion();
        
        vers.setName("§4 Test");
        
        
        e.getResponse().setVersion(new ServerPing.Protocol( "some random text", 2));
        player.setSample(new ServerPing.PlayerInfo[] {new ServerPing.PlayerInfo("here is some text aswell.", UUID.randomUUID()) });
        
        ping.setDescription("and a whole ton of randomt text here");
        
        e.setResponse(ping);

到目前为止,这就是我的代码。在屏幕截图中,您将看到结果。 但我不希望客户端的红色“x”超出日期消息。 我想要带有我自己的文本的在线内容。有任何想法吗? #(如果我将鼠标悬停在“文本”上,我会看到自己的文本,但如果我将鼠标悬停在“ping”上,我会收到 OutofDate 消息。)

这是带有注释的固定代码:

@EventHandler

public void onPing(ProxyPingEvent e) {
    ServerPing ping = e.getResponse();
    ServerPing.Players player = ping.getPlayers();
    ServerPing.Protocol vers = ping.getVersion();

    // change version text, but dont change version protocol id
    // because that causes the RED X in server browser
    vers.setName("Some version text");

    player.setSample(new ServerPing.PlayerInfo[] {
        new ServerPing.PlayerInfo("here is some text aswell.", UUID.randomUUID())
    });

    ping.setDescription("and a whole ton of randomt text here");

    e.setResponse(ping);
}