Class PaperServerListPingEvent
- All Implemented Interfaces:
Iterable<Player>
,Cancellable
ServerListPingEvent
that allows full control
of the response sent to the client.-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result
-
Constructor Summary
ConstructorDescriptionPaperServerListPingEvent
(@NotNull StatusClient client, @NotNull String motd, int numPlayers, int maxPlayers, @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) Deprecated.PaperServerListPingEvent
(@NotNull StatusClient client, Component motd, int numPlayers, int maxPlayers, @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) -
Method Summary
Modifier and TypeMethodDescriptiongetBukkitPlayer
(@NotNull Object player) Returns theStatusClient
pinging the server.int
Get the maximum number of players sent.int
Get the number of players sent.Returns a mutable list ofPlayerProfile
that will be displayed as online players on the client.int
Returns the protocol version that will be sent as the protocol version of the server to the client.Gets the server icon sent to the client.Returns the version that will be sent as server version on the client.boolean
Gets the cancellation state of this event.iterator()
void
setCancelled
(boolean cancel) Sets the cancellation state of this event.void
setHidePlayers
(boolean hidePlayers) Sets whether all player related information is hidden in the server list.void
setNumPlayers
(int numPlayers) Sets the number of players displayed in the server list.void
setProtocolVersion
(int protocolVersion) Sets the protocol version that will be sent as the protocol version of the server to the client.void
Sets the server icon sent to the client.void
setVersion
(@NotNull String version) Sets the version that will be sent as server version to the client.boolean
Returns whether all player related information is hidden in the server list.Methods inherited from class org.bukkit.event.server.ServerListPingEvent
getAddress, getHandlerList, getHandlers, getMotd, motd, motd, setMaxPlayers, setMotd
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
-
PaperServerListPingEvent
@Deprecated public PaperServerListPingEvent(@NotNull @NotNull StatusClient client, @NotNull @NotNull String motd, int numPlayers, int maxPlayers, @NotNull @NotNull String version, int protocolVersion, @Nullable @Nullable CachedServerIcon favicon) Deprecated. -
PaperServerListPingEvent
-
-
Method Details
-
getClient
Returns theStatusClient
pinging the server.- Returns:
- The client
-
getNumPlayers
public int getNumPlayers()Get the number of players sent.Returns
-1
if players are hidden usingshouldHidePlayers()
.- Overrides:
getNumPlayers
in classServerListPingEvent
- Returns:
- the number of players
-
setNumPlayers
public void setNumPlayers(int numPlayers) Sets the number of players displayed in the server list.Note that this won't have any effect if
shouldHidePlayers()
is enabled.- Parameters:
numPlayers
- The number of online players
-
getMaxPlayers
public int getMaxPlayers()Get the maximum number of players sent.Returns
-1
if players are hidden usingshouldHidePlayers()
.- Overrides:
getMaxPlayers
in classServerListPingEvent
- Returns:
- the maximum number of players
-
shouldHidePlayers
public boolean shouldHidePlayers()Returns whether all player related information is hidden in the server list. This will causegetNumPlayers()
,getMaxPlayers()
andgetPlayerSample()
to be skipped in the response.The Vanilla Minecraft client will display the player count as
???
when this option is enabled.- Returns:
true
if the player count is hidden
-
setHidePlayers
public void setHidePlayers(boolean hidePlayers) Sets whether all player related information is hidden in the server list. This will causegetNumPlayers()
,getMaxPlayers()
andgetPlayerSample()
to be skipped in the response.The Vanilla Minecraft client will display the player count as
???
when this option is enabled.- Parameters:
hidePlayers
-true
if the player count should be hidden
-
getPlayerSample
Returns a mutable list ofPlayerProfile
that will be displayed as online players on the client.The Vanilla Minecraft client will display them when hovering the player count with the mouse.
- Returns:
- The mutable player sample list
-
getVersion
Returns the version that will be sent as server version on the client.- Returns:
- The server version
-
setVersion
Sets the version that will be sent as server version to the client.- Parameters:
version
- The server version
-
getProtocolVersion
public int getProtocolVersion()Returns the protocol version that will be sent as the protocol version of the server to the client.- Returns:
- The protocol version of the server, or
-1
if the server has not finished initialization yet
-
setProtocolVersion
public void setProtocolVersion(int protocolVersion) Sets the protocol version that will be sent as the protocol version of the server to the client.- Parameters:
protocolVersion
- The protocol version of the server
-
getServerIcon
Gets the server icon sent to the client.- Returns:
- The icon to send to the client, or
null
for none
-
setServerIcon
Sets the server icon sent to the client.- Overrides:
setServerIcon
in classServerListPingEvent
- Parameters:
icon
- The icon to send to the client, ornull
for none
-
isCancelled
public boolean isCancelled()Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other pluginsCancelling this event will cause the connection to be closed immediately, without sending a response to the client.
- Specified by:
isCancelled
in interfaceCancellable
- Returns:
- true if this event is cancelled
-
setCancelled
public void setCancelled(boolean cancel) Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.Cancelling this event will cause the connection to be closed immediately, without sending a response to the client.
- Specified by:
setCancelled
in interfaceCancellable
- Parameters:
cancel
- true if you wish to cancel this event
-
iterator
Calling the
Iterator.remove()
method will force that particular player to not be displayed on the player list, decrease the size returned byServerListPingEvent.getNumPlayers()
, and will not be returned again by any new iterator.
Note: The players here will not be shown in the server info ifBukkit.getHideOnlinePlayers()
is true.Note: For compatibility reasons, this method will return all online players, not just the ones referenced in
getPlayerSample()
. Removing a player will:- Decrement the online player count (if and only if) the player count wasn't changed by another plugin before.
- Remove all entries from
getPlayerSample()
that refer to the removed player (based on theirUUID
).
- Specified by:
iterator
in interfaceIterable<Player>
- Overrides:
iterator
in classServerListPingEvent
-
getOnlinePlayers
-
getBukkitPlayer
-