Currently, there is no way short of manipulating packets to edit the information sent to a client when it pings the server. Here is the data sent to the client:
- A Message, the MOTD. (In vanilla, set with server.properties)
- A String, the Minecraft Version, such as "1.8". (In vanilla, the version of the server)
- An int, the Protocol Version, such as 47 (in 1.8) . (In vanilla, this is tied to the version of the server)
- A string that is a base64-encoded png stream, representing the server's icon prefixed with "data:image/png;base64,". (In vanilla, the icon in server-icon.png) (Note that in the API, this would be done by the implementation, and the exposed value would be a BufferedImage. Vanilla converter: https://gist.github.com/AlphaModder/7bddbd87e2f36ec38a68 )
- An int, the maximum players number. (In vanilla, set with server.properties)
- An int, the online players number. (In vanilla, simply how many players are online)
- A list of com.mojang.authlib.GameProfile objects, the players shown when mousing over the number of players. (In vanilla, there is a maximum of twelve players).
In the proposal, almost all of the data would be editable directly, except for two things: the GameProfiles and the online players number. These would be determined by a List that the plugin could edit, the players visible to the client. There would also be a way to override the default maximum of how many players are in the GameProfile list.
All of these are in my proposal except for the very last. Short of using GameProfile objects themselves, it may be difficult to represent these, since they are a string, the player's name, a UUID, the ID of the player, and a "com.mojang.authlib.properties.PropertyMap" which I am not sure of it's uses. It has name-value-"signature" triplets, and appears to somehow validate these signatures with a public key. I am not sure what to do with it. It's used for skins, and possibly other info. The server doesn't send it to the client in this case however so we can safely say there is no reason to modify it.
A second part of this would be to figure out how it is possible to change the MOTD without the client manually refreshing. It is either that the client does it automatically or that the server can force the client to refresh.
Anyway, here is my proposal so far.
/*
* This file is part of Sponge, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered.org <http://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.event.ping;
import java.awt.image.BufferedImage;
import java.net.InetSocketAddress;
import java.util.List;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.text.message.Message;
public interface ServerListPingEvent{
/**
* Get the address pinging the server.
* @return The address pinging the server.
*/
InetSocketAddress getAddress();
/**
* Get the MOTD that will be seen by the pinger.
* @return The MOTD that will be seen by the pinger.
*/
Message getMOTD();
/**
* Sets the MOTD that will be seen by the pinger.
* @param message The new message that will be seen by the pinger.
*/
void setMOTD(Message message);
/**
* Gets the Minecraft version that will be seen by the pinger.
* @return The Minecraft version that will be seen by the pinger.
*/
String getMCVersion();
/**
* Sets the Minecraft version that will be seen by the pinger.
* @param version The new Minecraft version that will be seen by the pinger.
*/
void setMCVersion(String version);
/**
* Gets the Protocol version that will be seen by the pinger.
* @return The Protocol version that will be seen by the pinger.
*/
int getProtocolVersion();
/**
* Sets the Protocol version that will be seen by the pinger.
* @param version The new Protocol version that will be seen by the pinger.
*/
void setProtocolVersion(int version);
/**
* Gets the image that will be seen by the pinger as the server's icon.
* @return The image that will be seen by the pinger as the server's icon.
*/
BufferedImage getFavicon();
/**
* Sets the image that will be seen by the pinger as the server's icon.
* @param image The new image that will be seen by the pinger as the server's icon.
*/
void setFavicon(BufferedImage image);
/**
* Gets the maximum players number that will be seen by the pinger.
* @return The maximum players number that will be seen by the pinger.
*/
int getMaximumPlayers();
/**
* Sets the maximum players number that will be seen by the pinger.
* @param maximumPlayers The new maximum players number that will be seen by the pinger.
*/
void setMaximumPlayers(int maximumPlayers);
/**
* Gets the players that will be seen by the pinger.
* @return The players that will be seen by the pinger.
*/
List<Player> getShownPlayers();
/**
* Sets the players that will be seen by the pinger.
* @param players The new players that will be seen by the pinger.
*/
void setShownPlayers(List<Player> players);
/**
* Gets the amount of players that will be seen in a list by the pinger.
* @return The amount of players that will be seen in a list by the pinger.
*/
int getMaximumListedPlayers();
/**
* Sets the amount of players that will be seen in a list by the pinger.
* @param players The new amount of players that will be seen in a list by the pinger.
*/
void setMaximumListedPlayers(int maximumListedPlayers);
}
The proposal also includes the removal of getMOTD from Server.java, because it is no longer guaranteed to be the MOTD shown to clients. I recommend a ServerProperties object under Server to store the configured MOTD, and other things in server.properties, but that is another Issue.