Class WrappedServerPing

java.lang.Object
com.comphenix.protocol.wrappers.WrappedServerPing
All Implemented Interfaces:
ClonableWrapper

public class WrappedServerPing extends Object implements ClonableWrapper
Represents a server ping packet data.
  • Constructor Details

    • WrappedServerPing

      public WrappedServerPing()
      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.

  • Method Details

    • fromHandle

      public static WrappedServerPing 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 WrappedServerPing 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.
      Returns:
      The message of the day.
    • setMotD

      public void setMotD(WrappedChatComponent description)
      Set the message of the day.
      Parameters:
      description - - message of the day.
    • setMotD

      public void setMotD(String message)
      Set the message of the day.
      Parameters:
      message - - the message.
    • getFavicon

      public WrappedServerPing.CompressedImage getFavicon()
      Retrieve the compressed PNG file that is being displayed as a favicon.
      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.
      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.
      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.
      Parameters:
      chatPreviewEnabled - true if enabled, false otherwise.
      Since:
      1.19
    • isEnforceSecureChat

      public boolean isEnforceSecureChat()
      Sets whether the server enforces secure chat.
      Returns:
      whether the server enforces secure chat.
      Since:
      1.19.1
    • setEnforceSecureChat

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

      public int getPlayersOnline()
      Retrieve the displayed number of online players.
      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.

      Parameters:
      online - - online players.
    • getPlayersMaximum

      public int getPlayersMaximum()
      Retrieve the displayed maximum number of players.
      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.

      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.

      Parameters:
      visible - - TRUE if it should be visible, FALSE otherwise.
    • isPlayersVisible

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

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

      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.
      Returns:
      Logged in players or an empty list if no player names will be displayed.
    • setPlayers

      public void setPlayers(Iterable<? extends WrappedGameProfile> profile)
      Set the displayed list of logged in players.
      Parameters:
      profile - - every logged in player.
    • setBukkitPlayers

      public void setBukkitPlayers(Iterable<? extends org.bukkit.entity.Player> players)
      Set the displayed lst of logged in players.
      Parameters:
      players - - the players to display.
    • getVersionName

      public String getVersionName()
      Retrieve the version name of the current server.
      Returns:
      The version name.
    • setVersionName

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

      public int getVersionProtocol()
      Retrieve the protocol number.
      Returns:
      The protocol.
    • setVersionProtocol

      public void setVersionProtocol(int protocol)
      Set the version protocol
      Parameters:
      protocol - - the protocol number.
    • getHandle

      public Object getHandle()
      Specified by:
      getHandle in interface ClonableWrapper
    • deepClone

      public WrappedServerPing deepClone()
      Retrieve a deep copy of the current wrapper object.
      Specified by:
      deepClone in interface ClonableWrapper
      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 Object
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object