Package org.bukkit.event.server

# Class ServerListPingEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.server.ServerEvent
org.bukkit.event.server.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.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.bukkit.event.Event

`Event.Result`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`ServerListPingEvent(@NotNull InetAddress address, @NotNull String motd, int maxPlayers)`
Deprecated.
in favour of `ServerListPingEvent(java.net.InetAddress, net.kyori.adventure.text.Component, int)`
``
`ServerListPingEvent(@NotNull InetAddress address, @NotNull String motd, int numPlayers, int maxPlayers)`
Deprecated.
`protected`
`ServerListPingEvent(@NotNull InetAddress address, Component motd, int maxPlayers)`
This constructor is intended for implementations that provide the `iterator()` method, thus provided the `getNumPlayers()` count.
``
`ServerListPingEvent(@NotNull InetAddress address, Component motd, int numPlayers, int maxPlayers)`

## Method Summary

Modifier and Type
Method
Description
`@NotNull InetAddress`
`getAddress()`
Get the address the ping is coming from.
`static @NotNull HandlerList`
`getHandlerList()`
`@NotNull HandlerList`
`getHandlers()`
`int`
`getMaxPlayers()`
Get the maximum number of players sent.
`@NotNull String`
`getMotd()`
Deprecated.
in favour of `motd()`
`int`
`getNumPlayers()`
Get the number of players sent.
`@NotNull Iterator<Player>`
`iterator()`
`Component`
`motd()`
Get the message of the day message.
`void`
`motd(Component motd)`
Change the message of the day message.
`void`
`setMaxPlayers(int maxPlayers)`
Set the maximum number of players sent.
`void`
`setMotd(@NotNull String motd)`
Deprecated.
in favour of `motd(net.kyori.adventure.text.Component)`
`void`
`setServerIcon(CachedServerIcon icon)`
Sets the server-icon sent to the client.

### Methods inherited from class org.bukkit.event.Event

`callEvent, getEventName, isAsynchronous`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

## Constructor Details

### ServerListPingEvent

@Deprecated public ServerListPingEvent(@NotNull @NotNull InetAddress address, @NotNull @NotNull String motd, int numPlayers, int maxPlayers)
Deprecated.

### ServerListPingEvent

@Deprecated protected ServerListPingEvent(@NotNull @NotNull InetAddress address, @NotNull @NotNull String motd, int maxPlayers)
Deprecated.
in favour of `ServerListPingEvent(java.net.InetAddress, net.kyori.adventure.text.Component, int)`
This constructor is intended for implementations that provide the `iterator()` method, thus provided the `getNumPlayers()` count.

Parameters:
  `address` - the address of the pinger
  `motd` - the message of the day
  `maxPlayers` - the max number of players

### ServerListPingEvent

public ServerListPingEvent(@NotNull @NotNull InetAddress address, @NotNull Component motd, int numPlayers, int maxPlayers)

### ServerListPingEvent

protected ServerListPingEvent(@NotNull @NotNull InetAddress address, @NotNull Component motd, int maxPlayers)
This constructor is intended for implementations that provide the `iterator()` method, thus provided the `getNumPlayers()` count.

Parameters:
  `address` - the address of the pinger
  `motd` - the message of the day
  `maxPlayers` - the max number of players

## Method Details

### motd

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

Returns:
  the message of the day

### motd

public void motd(@NotNull Component motd)
Change the message of the day message.

Parameters:
  `motd` - the message of the day

### getAddress

@NotNull public @NotNull InetAddress getAddress()
Get the address the ping is coming from.

Returns:
  the address

### 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(net.kyori.adventure.text.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

### setServerIcon

public void setServerIcon(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

### getHandlers

@NotNull public @NotNull HandlerList getHandlers()

Specified by:
  `getHandlers` in class `Event`

### getHandlerList

@NotNull public static @NotNull HandlerList getHandlerList()

### iterator

@NotNull public @NotNull Iterator<Player> iterator() throws UnsupportedOperationException

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.

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