Class ServerPing

java.lang.Object
com.velocitypowered.api.proxy.server.ServerPing

public final class ServerPing extends Object
Represents a 1.7 and above server list ping response. This class is immutable.
  • Constructor Details

    • ServerPing

      public ServerPing(ServerPing.Version version, @Nullable ServerPing.Players players, Component description, @Nullable Favicon favicon)
      Constructs an initial ServerPing instance.
      Parameters:
      version - the version of the server
      players - the players on the server, or null if not shown
      description - the MOTD for the server
      favicon - the server's favicon, or null if not set
    • ServerPing

      public ServerPing(ServerPing.Version version, @Nullable ServerPing.Players players, Component description, @Nullable Favicon favicon, @Nullable ModInfo modinfo)
      Constructs a ServerPing instance.
      Parameters:
      version - the version of the server
      players - the players on the server
      description - the MOTD for the server
      favicon - the server's favicon
      modinfo - the mods this server runs
  • Method Details

    • getVersion

      public ServerPing.Version getVersion()
      Gets the version shown to the client during the ping.
      Returns:
      the version
    • getPlayers

      public Optional<ServerPing.Players> getPlayers()
      Gets the player information shown to the client.
      Returns:
      the player information, or empty if not shown
    • getDescriptionComponent

      public @Nullable Component getDescriptionComponent()
      Gets the description (MOTD) component shown in the ping response.
      Returns:
      the description component
    • getFavicon

      public Optional<Favicon> getFavicon()
      Gets the favicon sent to the client.
      Returns:
      the favicon, or empty if not present
    • getModinfo

      public Optional<ModInfo> getModinfo()
      Gets the mod info sent to the client.
      Returns:
      the mod info, or empty if not present
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • asBuilder

      public ServerPing.Builder asBuilder()
      Returns a copy of this ServerPing instance as a builder so that it can be modified. It is guaranteed that ping.asBuilder().build().equals(ping) is true: that is, if no other changes are made to the returned builder, the built instance will equal the original instance.
      Returns:
      a copy of this instance as a ServerPing.Builder
    • builder

      public static ServerPing.Builder builder()
      Creates a new ServerPing.Builder for constructing a ServerPing.
      Returns:
      a new ServerPing builder