Class LegacyServerPing

java.lang.Object
com.comphenix.protocol.wrappers.AbstractWrapper
com.comphenix.protocol.wrappers.ping.LegacyServerPing
All Implemented Interfaces:
ServerPingImpl, Cloneable

public final class LegacyServerPing extends AbstractWrapper implements ServerPingImpl
Represents a server ping packet data.
  • Constructor Details

    • LegacyServerPing

      public LegacyServerPing()
      Construct a new server ping initialized with a zero player count, and zero maximum.

      Note that the version string is set to 1.9.4.

    • LegacyServerPing

      public LegacyServerPing(Object handle)
  • Method Details

    • resetPlayers

      public void resetPlayers()
      Set the player count and player maximum to the default values.
      Specified by:
      resetPlayers in interface ServerPingImpl
    • resetVersion

      public void resetVersion()
      Reset the version string to the default state.
      Specified by:
      resetVersion in interface ServerPingImpl
    • fromHandle

      public static LegacyServerPing fromHandle(Object handle)
      Construct a wrapped server ping from a native NMS object.
      Parameters:
      handle - - the native object.
      Returns:
      The wrapped server ping object.
    • fromJson

      public static LegacyServerPing fromJson(String json)
      Construct a wrapper server ping from an encoded JSON string.
      Parameters:
      json - - the JSON string.
      Returns:
      The wrapped server ping.
    • getMotD

      public WrappedChatComponent getMotD()
      Retrieve the message of the day.
      Specified by:
      getMotD in interface ServerPingImpl
      Returns:
      The message of the day.
    • setMotD

      public void setMotD(WrappedChatComponent description)
      Set the message of the day.
      Specified by:
      setMotD in interface ServerPingImpl
      Parameters:
      description - - message of the day.
    • getFavicon

      public WrappedServerPing.CompressedImage getFavicon()
      Retrieve the compressed PNG file that is being displayed as a favicon.
      Specified by:
      getFavicon in interface ServerPingImpl
      Returns:
      The favicon, or NULL if no favicon will be displayed.
    • setFavicon

      public void setFavicon(WrappedServerPing.CompressedImage image)
      Set the compressed PNG file that is being displayed.
      Specified by:
      setFavicon in interface ServerPingImpl
      Parameters:
      image - - the new compressed image or NULL if no favicon should be displayed.
    • isChatPreviewEnabled

      @Deprecated public boolean isChatPreviewEnabled()
      Deprecated.
      Removed in 1.19.3
      Retrieve whether chat preview is enabled on the server.
      Specified by:
      isChatPreviewEnabled in interface ServerPingImpl
      Returns:
      whether chat preview is enabled on the server.
      Since:
      1.19
    • setChatPreviewEnabled

      @Deprecated public void setChatPreviewEnabled(boolean chatPreviewEnabled)
      Deprecated.
      Removed in 1.19.3
      Sets whether chat preview is enabled on the server.
      Specified by:
      setChatPreviewEnabled in interface ServerPingImpl
      Parameters:
      chatPreviewEnabled - true if enabled, false otherwise.
      Since:
      1.19
    • isEnforceSecureChat

      public boolean isEnforceSecureChat()
      Sets whether the server enforces secure chat.
      Specified by:
      isEnforceSecureChat in interface ServerPingImpl
      Returns:
      whether the server enforces secure chat.
      Since:
      1.19.1
    • setEnforceSecureChat

      public void setEnforceSecureChat(boolean enforceSecureChat)
      Sets whether the server enforces secure chat.
      Specified by:
      setEnforceSecureChat in interface ServerPingImpl
      Parameters:
      enforceSecureChat - true if enabled, false otherwise.
      Since:
      1.19.1
    • getPlayersOnline

      public int getPlayersOnline()
      Retrieve the displayed number of online players.
      Specified by:
      getPlayersOnline in interface ServerPingImpl
      Returns:
      The displayed number.
      Throws:
      IllegalStateException - If the player count has been hidden via setPlayersVisible(boolean).
      See Also:
    • setPlayersOnline

      public void setPlayersOnline(int online)
      Set the displayed number of online players.

      As of 1.7.2, this is completely unrestricted, and can be both positive and negative, as well as higher than the player maximum.

      Specified by:
      setPlayersOnline in interface ServerPingImpl
      Parameters:
      online - - online players.
    • getPlayersMaximum

      public int getPlayersMaximum()
      Retrieve the displayed maximum number of players.
      Specified by:
      getPlayersMaximum in interface ServerPingImpl
      Returns:
      The maximum number.
      Throws:
      IllegalStateException - If the player maximum has been hidden via setPlayersVisible(boolean).
      See Also:
    • setPlayersMaximum

      public void setPlayersMaximum(int maximum)
      Set the displayed maximum number of players.

      The 1.7.2 accepts any value as a player maximum, positive or negative. It even permits a player maximum that is less than the player count.

      Specified by:
      setPlayersMaximum in interface ServerPingImpl
      Parameters:
      maximum - - maximum player count.
    • setPlayersVisible

      public void setPlayersVisible(boolean visible)
      Set whether or not the player count and player maximum is visible.

      Note that this may set the current player count and maximum to their respective real values.

      Specified by:
      setPlayersVisible in interface ServerPingImpl
      Parameters:
      visible - - TRUE if it should be visible, FALSE otherwise.
    • getJson

      public String getJson()
      Specified by:
      getJson in interface ServerPingImpl
    • arePlayersVisible

      public boolean arePlayersVisible()
      Determine if the player count and maximum is visible.

      If not, the client will display ??? in the same location.

      Specified by:
      arePlayersVisible in interface ServerPingImpl
      Returns:
      TRUE if the player statistics is visible, FALSE otherwise.
    • getPlayers

      public com.google.common.collect.ImmutableList<WrappedGameProfile> getPlayers()
      Retrieve a copy of all the logged in players.
      Specified by:
      getPlayers in interface ServerPingImpl
      Returns:
      Logged in players or an empty list if no player names will be displayed.
    • setPlayers

      public void setPlayers(Iterable<? extends WrappedGameProfile> playerSample)
      Set the displayed list of logged in players.
      Specified by:
      setPlayers in interface ServerPingImpl
      Parameters:
      playerSample - - every logged in player.
    • getVersionName

      public String getVersionName()
      Retrieve the version name of the current server.
      Specified by:
      getVersionName in interface ServerPingImpl
      Returns:
      The version name.
    • setVersionName

      public void setVersionName(String name)
      Set the version name of the current server.
      Specified by:
      setVersionName in interface ServerPingImpl
      Parameters:
      name - - the new version name.
    • getVersionProtocol

      public int getVersionProtocol()
      Retrieve the protocol number.
      Specified by:
      getVersionProtocol in interface ServerPingImpl
      Returns:
      The protocol.
    • setVersionProtocol

      public void setVersionProtocol(int protocol)
      Set the version protocol
      Specified by:
      setVersionProtocol in interface ServerPingImpl
      Parameters:
      protocol - - the protocol number.
    • deepClone

      public LegacyServerPing deepClone()
      Retrieve a deep copy of the current wrapper object.
      Returns:
      The current object.
    • toJson

      public String toJson()
      Retrieve the underlying JSON representation of this server ping.
      Returns:
      The JSON representation.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractWrapper