title: Problem with the protocol. MinecraftPing class
body: <p>I am using this method but I get an error necessary for the version (PaperSpigot 1.15.2):</p>
  
  <pre><code>public MinecraftPingReply getPing(final MinecraftPingOptions options) throws IOException {
          MinecraftPingUtil.validate(options.getHostname(), "Hostname cannot be null.");
          MinecraftPingUtil.validate(options.getPort(), "Port cannot be null.");
  
          final Socket socket = new Socket();
          socket.connect(new InetSocketAddress(options.getHostname(), options.getPort()), options.getTimeout());
  
          final DataInputStream in = new DataInputStream(socket.getInputStream());
          final DataOutputStream out = new DataOutputStream(socket.getOutputStream());
  
          //&gt; Handshake
  
          ByteArrayOutputStream handshake_bytes = new ByteArrayOutputStream();
          DataOutputStream handshake = new DataOutputStream(handshake_bytes);
  
          handshake.writeByte(MinecraftPingUtil.PACKET_HANDSHAKE);
          MinecraftPingUtil.writeVarInt(handshake, MinecraftPingUtil.PROTOCOL_VERSION);
          MinecraftPingUtil.writeVarInt(handshake, options.getHostname().length());
          handshake.writeBytes(options.getHostname());
          handshake.writeShort(options.getPort());
          MinecraftPingUtil.writeVarInt(handshake, MinecraftPingUtil.STATUS_HANDSHAKE);
  
          MinecraftPingUtil.writeVarInt(out, handshake_bytes.size());
          out.write(handshake_bytes.toByteArray());
  
          //&gt; Status request
  
          out.writeByte(0x01); // Size of packet
          out.writeByte(MinecraftPingUtil.PACKET_STATUSREQUEST);
  
          //&lt; Status response
  
          MinecraftPingUtil.readVarInt(in); // Size
          int id = MinecraftPingUtil.readVarInt(in);
  
          MinecraftPingUtil.io(id == -1, "Server prematurely ended stream.");
          MinecraftPingUtil.io(id != MinecraftPingUtil.PACKET_STATUSREQUEST, "Server returned invalid packet.");
  
          int length = MinecraftPingUtil.readVarInt(in);
          MinecraftPingUtil.io(length == -1, "Server prematurely ended stream.");
          MinecraftPingUtil.io(length == 0, "Server returned unexpected value.");
  
          byte[] data = new byte[length];
          in.readFully(data);
          String json = new String(data, options.getCharset());
  
          //&gt; Ping
  
          out.writeByte(0x09); // Size of packet
          out.writeByte(MinecraftPingUtil.PACKET_PING);
          out.writeLong(System.currentTimeMillis());
  
          //&lt; Ping
  
          MinecraftPingUtil.readVarInt(in); // Size
          id = MinecraftPingUtil.readVarInt(in);
          MinecraftPingUtil.io(id == -1, "Server prematurely ended stream.");
          MinecraftPingUtil.io(id != MinecraftPingUtil.PACKET_PING, "Server returned invalid packet.");
  
          // Close
  
          handshake.close();
          handshake_bytes.close();
          out.close();
          in.close();
          socket.close();
  
          return new Gson().fromJson(json, MinecraftPingReply.class);
      }
  
  
  
  
  public class MinecraftPingUtil {
  
      public static byte PACKET_HANDSHAKE = 0x00, PACKET_STATUSREQUEST = 0x00,
              PACKET_PING = 0x01;
      public static int PROTOCOL_VERSION = 4;
      public static int STATUS_HANDSHAKE = 1;
  
      public static void validate(final Object o, final String m) {
          if (o == null) {
              throw new RuntimeException(m);
          }
      }
  
      public static void io(final boolean b, final String m) throws IOException {
          if (b) {
              throw new IOException(m);
          }
      }
  
      /**
       * @author thinkofdeath
       * See: https://gist.github.com/thinkofdeath/e975ddee04e9c87faf22
       */
      public static int readVarInt(DataInputStream in) throws IOException {
          int i = 0;
          int j = 0;
          while (true) {
              int k = in.readByte();
  
              i |= (k &amp; 0x7F) &lt;&lt; j++ * 7;
  
              if (j &gt; 5)
                  throw new RuntimeException("VarInt too big");
  
              if ((k &amp; 0x80) != 128)
                  break;
          }
  
          return i;
      }
  
      /**
       * @author thinkofdeath
       * See: https://gist.github.com/thinkofdeath/e975ddee04e9c87faf22
       * @throws IOException 
       */
      public static void writeVarInt(DataOutputStream out, int paramInt) throws IOException {
          while (true) {
              if ((paramInt &amp; 0xFFFFFF80) == 0) {
                  out.writeByte(paramInt);
                  return;
              }
  
              out.writeByte(paramInt &amp; 0x7F | 0x80);
              paramInt &gt;&gt;&gt;= 7;
          }
      }
  
  }
  </code></pre>
  
  <p>More info: <a href="https://github.com/oliverdunk/MinecraftServerPing/tree/master/src/ch/jamiete/mcping" rel="nofollow noreferrer">https://github.com/oliverdunk/MinecraftServerPing/tree/master/src/ch/jamiete/mcping</a></p>
  
  <p>(for a Minecraft plugin) This version works with 1.8 and not in the version I need: 1.15.2
  How can I solve it?</p>
  
  <p>Error:</p>
  
  <p>Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 17 path $.description
      at com.google.gson.stream.JsonReader.nextString(JsonReader.java:825) ~[patched_1.15.2.jar:git-Paper-318]
      at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:418) ~[patched_1.15.2.jar:git-Paper-318]
      at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:406) ~[patched_1.15.2.jar:git-Paper-318]
      at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) ~[patched_1.15.2.jar:git-Paper-318]
      at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) ~[patched_1.15.2.jar:git-Paper-318]
      at com.google.gson.Gson.fromJson(Gson.java:887) ~[patched_1.15.2.jar:git-Paper-318]
      at com.google.gson.Gson.fromJson(Gson.java:852) ~[patched_1.15.2.jar:git-Paper-318]
      at com.google.gson.Gson.fromJson(Gson.java:801) ~[patched_1.15.2.jar:git-Paper-318]
      at com.google.gson.Gson.fromJson(Gson.java:773) ~[patched_1.15.2.jar:git-Paper-318]
      at it.justdevs.bw.lobby.utils.ping.MinecraftPing.getPing(MinecraftPing.java:121) ~[?:?]
      at it.justdevs.bw.lobby.utils.StatusItemStack.getItemStack(StatusItemStack.java:51) ~[?:?]
      at it.justdevs.bw.lobby.guis.Inventory.init(Inventory.java:38) ~[?:?]
      at it.justdevs.gui.utils.SmartInventory.open(SmartInventory.java:54) ~[?:?]
      at it.justdevs.gui.utils.SmartInventory.open(SmartInventory.java:37) ~[?:?]
      at it.justdevs.bw.lobby.commands.MainCommand.onCommand(MainCommand.java:26) ~[?:?]
      at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.15.2.jar:git-Paper-318]</p>