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
ConstructorsConstructorDescriptionPaperServerListPingEvent(@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 theStatusClientpinging the server.intGet the maximum number of players sent.intGet the number of players sent.Returns a mutable list ofPlayerProfilethat will be displayed as online players on the client.intReturns 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.booleanGets the cancellation state of this event.iterator()voidsetCancelled(boolean cancel) Sets the cancellation state of this event.voidsetHidePlayers(boolean hidePlayers) Sets whether all player related information is hidden in the server list.voidsetNumPlayers(int numPlayers) Sets the number of players displayed in the server list.voidsetProtocolVersion(int protocolVersion) Sets the protocol version that will be sent as the protocol version of the server to the client.voidSets the server icon sent to the client.voidsetVersion(@NotNull String version) Sets the version that will be sent as server version to the client.booleanReturns whether all player related information is hidden in the server list.Methods inherited from class org.bukkit.event.server.ServerListPingEvent
getAddress, getHandlerList, getHandlers, getHostname, getMotd, motd, motd, setMaxPlayers, setMotd, shouldSendChatPreviewsMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronousMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 theStatusClientpinging the server.- Returns:
- The client
-
getNumPlayers
public int getNumPlayers()Get the number of players sent.Returns
-1if players are hidden usingshouldHidePlayers().- Overrides:
getNumPlayersin 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
-1if players are hidden usingshouldHidePlayers().- Overrides:
getMaxPlayersin 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:
trueif 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-trueif the player count should be hidden
-
getPlayerSample
Returns a mutable list ofPlayerProfilethat 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
-1if 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
nullfor none
-
setServerIcon
Sets the server icon sent to the client.- Overrides:
setServerIconin classServerListPingEvent- Parameters:
icon- The icon to send to the client, ornullfor 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:
isCancelledin 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:
setCancelledin 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:
iteratorin interfaceIterable<Player>- Overrides:
iteratorin classServerListPingEvent
-
getOnlinePlayers
-
getBukkitPlayer
-