Class ServerListPingEvent

All Implemented Interfaces:
Iterable<Player>
Direct Known Subclasses:
PaperServerListPingEvent

public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
Called when a server list ping is coming in. Displayed players can be checked and removed by iterating over this event.
Note: The players in iterator() will not be shown in the server info if Bukkit.getHideOnlinePlayers() is true.
  • Constructor Details

    • ServerListPingEvent

      @Internal @Deprecated(forRemoval=true) public ServerListPingEvent(@NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address, @NotNull @NotNull String motd, int numPlayers, int maxPlayers)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • ServerListPingEvent

      @Internal @Deprecated(forRemoval=true) protected ServerListPingEvent(@NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address, @NotNull @NotNull String motd, int maxPlayers)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • ServerListPingEvent

      @Internal @Deprecated(forRemoval=true) public ServerListPingEvent(@NotNull @NotNull InetAddress address, @NotNull @NotNull Component motd, int numPlayers, int maxPlayers)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • ServerListPingEvent

      @Internal public ServerListPingEvent(@NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address, @NotNull @NotNull Component motd, int numPlayers, int maxPlayers)
    • ServerListPingEvent

      @Internal @Deprecated(forRemoval=true) protected ServerListPingEvent(@NotNull @NotNull InetAddress address, @NotNull @NotNull Component motd, int maxPlayers)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • ServerListPingEvent

      @Internal protected ServerListPingEvent(@NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address, @NotNull @NotNull Component motd, int maxPlayers)
  • Method Details

    • getHostname

      @NotNull public @NotNull String getHostname()
      Gets the hostname that the player used to connect to the server, or blank if unknown
      Returns:
      The hostname
    • getAddress

      @NotNull public @NotNull InetAddress getAddress()
      Get the address the ping is coming from.
      Returns:
      the address
    • motd

      @NotNull public @NotNull Component motd()
      Get the message of the day message.
      Returns:
      the message of the day
    • motd

      public void motd(@NotNull @NotNull Component motd)
      Change the message of the day message.
      Parameters:
      motd - the message of the day
    • getMotd

      @NotNull @Deprecated public @NotNull String getMotd()
      Deprecated.
      in favour of motd()
      Get the message of the day message.
      Returns:
      the message of the day
    • setMotd

      @Deprecated public void setMotd(@NotNull @NotNull String motd)
      Deprecated.
      in favour of motd(Component)
      Change the message of the day message.
      Parameters:
      motd - the message of the day
    • getNumPlayers

      public int getNumPlayers()
      Get the number of players sent.
      Returns:
      the number of players
    • getMaxPlayers

      public int getMaxPlayers()
      Get the maximum number of players sent.
      Returns:
      the maximum number of players
    • setMaxPlayers

      public void setMaxPlayers(int maxPlayers)
      Set the maximum number of players sent.
      Parameters:
      maxPlayers - the maximum number of player
    • shouldSendChatPreviews

      @Contract("-> false") @Deprecated(since="1.19.3", forRemoval=true) public boolean shouldSendChatPreviews()
      Deprecated, for removal: This API element is subject to removal in a future version.
      chat previews have been removed
      Gets whether the server needs to send a preview of the chat to the client.
      Returns:
      true if chat preview is enabled, false otherwise
    • setServerIcon

      public void setServerIcon(@UndefinedNullability("implementation dependent") CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException
      Sets the server-icon sent to the client.
      Parameters:
      icon - the icon to send to the client
      Throws:
      IllegalArgumentException - if the CachedServerIcon is not created by the caller of this event; null may be accepted for some implementations
      UnsupportedOperationException - if the caller of this event does not support setting the server icon
    • iterator

      @NotNull @Deprecated(forRemoval=true, since="1.20.6") public @NotNull Iterator<Player> iterator() throws UnsupportedOperationException
      Deprecated, for removal: This API element is subject to removal in a future version.
      the Iterable interface will be removed at some point

      Calling the Iterator.remove() method will force that particular player to not be displayed on the player list, decrease the size returned by getNumPlayers(), and will not be returned again by any new iterator.
      Note: The players here will not be shown in the server info if Bukkit.getHideOnlinePlayers() is true.

      Specified by:
      iterator in interface Iterable<Player>
      Throws:
      UnsupportedOperationException - if the caller of this event does not support removing players
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()