public class PaperServerListPingEvent extends ServerListPingEvent implements Cancellable
ServerListPingEvent that allows full control
of the response sent to the client.Event.Result| Constructor and Description |
|---|
PaperServerListPingEvent(StatusClient client,
String motd,
int numPlayers,
int maxPlayers,
String version,
int protocolVersion,
CachedServerIcon favicon) |
| Modifier and Type | Method and 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.
|
List<String> |
getSampleText()
Deprecated.
|
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 |
setSampleText(List<String> sample)
Deprecated.
|
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.
|
getAddress, getHandlerList, getHandlers, getMotd, setMaxPlayers, setMotdcallEvent, getEventName, isAsynchronousclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic PaperServerListPingEvent(@Nonnull StatusClient client, String motd, int numPlayers, int maxPlayers, @Nonnull String version, int protocolVersion, @Nullable CachedServerIcon favicon)
@Nonnull 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@Nonnull 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.
@Nonnull public String getVersion()
public void setVersion(@Nonnull String version)
version - The server versionpublic int getProtocolVersion()
public 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@Nonnull 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 ServerListPingEventprotected Object[] getOnlinePlayers()
@Deprecated public List<String> getSampleText()
getSampleText in class ServerListPingEvent@Deprecated public void setSampleText(List<String> sample)
setSampleText in class ServerListPingEventsample - the new player list sampleCopyright © 2021. All rights reserved.