How to create hover text in the serverlist menu using a JsonObject?

Discussion in 'Spigot Plugin Development' started by retrodaredevil, Jun 14, 2016.

  1. Hi,
    Recently someone else asked how to do this and I gave it my best guess. I then started coding trying to make the player count whatever I wanted using reflection, it worked (Not how many players are online, just whatever string I wanted). Now, I am trying to get hover text or do something cool with what I did. In PacketPlayOutServerInfo there's a line like this: " private static final Gson a = new GsonBuilder()......create();" I found a way to override that do instead of this: "registerTypeAdapter(ServerPing.ServerData.class, new ServerPing.ServerData.Serializer())" I got this: ".registerTypeAdapter(ServerPing.ServerData.class, new OverridenSerializer())"
    The overridenSerializer class looks like this:
    Code (Java):

        public static class OverridenSerializer extends ServerPing.ServerData.Serializer{
            public JsonElement a(ServerData serverData, Type type, JsonSerializationContext jsonSerializationContext) {
                JsonObject jsonObject = new JsonObject();
                jsonObject.addProperty("name", serverData.a());
                jsonObject.addProperty("protocol", serverData.getProtocolVersion());
                jsonObject.addProperty("hover", "You are hovering right now"); // I tried "hover" and "hoverEvent"
                System.out.println("Haha it has been overriden!!!");
                return jsonObject;
    I was able to listen for PacketPlayOutServerInfo and when I pinged the server, it said "Haha it has been overriden!!!" in the console. I'm not very familiar with JsonObject and the different properties that I can add. The hover property does nothing and I was wondering if anyone knows a place that lists all the different json stuff specifically for the server menu.

    Also, do I need to be overriding a different Serializer?