Iterable<Player>, Cancellablepublic class PaperServerListPingEvent extends ServerListPingEvent implements Cancellable
ServerListPingEvent that allows full control
of the response sent to the client.Event.Result| Constructor | Description |
|---|---|
PaperServerListPingEvent(StatusClient client,
String motd,
int numPlayers,
int maxPlayers,
String version,
int protocolVersion,
CachedServerIcon favicon) |
| Modifier and Type | Method | Description |
|---|---|---|
protected Player |
getBukkitPlayer(Object player) |
|
StatusClient |
getClient() |
Returns the
StatusClient pinging the server. |
int |
getMaxPlayers() |
Get the maximum number of players sent.
|
int |
getNumPlayers() |
Get the number of players sent.
|
protected Object[] |
getOnlinePlayers() |
|
List<PlayerProfile> |
getPlayerSample() |
Returns a mutable list of
PlayerProfile that will be displayed
as online players on the client. |
int |
getProtocolVersion() |
Returns the protocol version that will be sent as the protocol version
of the server to the client.
|
CachedServerIcon |
getServerIcon() |
Gets the server icon sent to the client.
|
String |
getVersion() |
Returns the version that will be sent as server version on the client.
|
boolean |
isCancelled() |
Gets the cancellation state of this event.
|
Iterator<Player> |
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 |
setServerIcon(CachedServerIcon icon) |
Sets the server icon sent to the client.
|
void |
setVersion(String version) |
Sets the version that will be sent as server version to the client.
|
boolean |
shouldHidePlayers() |
Returns whether all player related information is hidden in the server
list.
|
callEvent, getEventName, isAsynchronousforEach, spliteratorclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAddress, getHandlerList, getHandlers, getMotd, setMaxPlayers, setMotdpublic PaperServerListPingEvent(@NotNull
StatusClient client,
@NotNull
String motd,
int numPlayers,
int maxPlayers,
@NotNull
String version,
int protocolVersion,
@Nullable
CachedServerIcon favicon)
@NotNull public StatusClient getClient()
StatusClient pinging the server.public int getNumPlayers()
Returns -1 if players are hidden using
shouldHidePlayers().
getNumPlayers in class ServerListPingEventpublic void setNumPlayers(int numPlayers)
Note that this won't have any effect if shouldHidePlayers()
is enabled.
numPlayers - The number of online playerspublic int getMaxPlayers()
Returns -1 if players are hidden using
shouldHidePlayers().
getMaxPlayers in class ServerListPingEventpublic boolean shouldHidePlayers()
getNumPlayers(), getMaxPlayers()
and getPlayerSample() to be skipped in the response.
The Vanilla Minecraft client will display the player count as ???
when this option is enabled.
true if the player count is hiddenpublic void setHidePlayers(boolean hidePlayers)
getNumPlayers(), getMaxPlayers()
and getPlayerSample() to be skipped in the response.
The Vanilla Minecraft client will display the player count as ???
when this option is enabled.
hidePlayers - true if the player count should be hidden@NotNull public List<PlayerProfile> getPlayerSample()
PlayerProfile 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.
@NotNull public String getVersion()
public void setVersion(@NotNull
String version)
version - The server versionpublic int getProtocolVersion()
-1 if the server
has not finished initialization yetpublic void setProtocolVersion(int protocolVersion)
protocolVersion - The protocol version of the server@Nullable public CachedServerIcon getServerIcon()
null for nonepublic void setServerIcon(@Nullable
CachedServerIcon icon)
setServerIcon in class ServerListPingEventicon - The icon to send to the client, or null for nonepublic boolean isCancelled()
Cancelling this event will cause the connection to be closed immediately, without sending a response to the client.
isCancelled in interface Cancellablepublic void setCancelled(boolean cancel)
Cancelling this event will cause the connection to be closed immediately, without sending a response to the client.
setCancelled in interface Cancellablecancel - true if you wish to cancel this event@NotNull public Iterator<Player> iterator()
Calling the Iterator.remove() method will force that particular
player to not be displayed on the player list, decrease the size
returned by ServerListPingEvent.getNumPlayers(), and will not be returned again by
any new iterator.
Note: For compatibility reasons, this method will return all
online players, not just the ones referenced in getPlayerSample().
Removing a player will:
getPlayerSample() that refer to
the removed player (based on their UUID).iterator in interface Iterable<Player>iterator in class ServerListPingEvent@NotNull protected Object[] getOnlinePlayers()
Copyright © 2020. All rights reserved.