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(@NotNull StatusClient client,
net.kyori.adventure.text.Component motd,
int numPlayers,
int maxPlayers,
@NotNull String version,
int protocolVersion,
@Nullable CachedServerIcon favicon) |
PaperServerListPingEvent(@NotNull StatusClient client,
@NotNull String motd,
int numPlayers,
int maxPlayers,
@NotNull String version,
int protocolVersion,
@Nullable CachedServerIcon favicon)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected @NotNull Player |
getBukkitPlayer(@NotNull Object player) |
@NotNull 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 @NotNull Object[] |
getOnlinePlayers() |
@NotNull 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.
|
@Nullable CachedServerIcon |
getServerIcon()
Gets the server icon sent to the client.
|
@NotNull String |
getVersion()
Returns the version that will be sent as server version on the client.
|
boolean |
isCancelled()
Gets the cancellation state of this event.
|
@NotNull 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(@Nullable CachedServerIcon icon)
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 |
shouldHidePlayers()
Returns whether all player related information is hidden in the server
list.
|
getAddress, getHandlerList, getHandlers, getMotd, motd, motd, setMaxPlayers, setMotd
callEvent, getEventName, isAsynchronous
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
@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)
public PaperServerListPingEvent(@NotNull @NotNull StatusClient client, @NotNull net.kyori.adventure.text.Component motd, int numPlayers, int maxPlayers, @NotNull @NotNull String version, int protocolVersion, @Nullable @Nullable CachedServerIcon favicon)
@NotNull public @NotNull StatusClient getClient()
StatusClient
pinging the server.public int getNumPlayers()
Returns -1
if players are hidden using
shouldHidePlayers()
.
getNumPlayers
in class ServerListPingEvent
public 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 ServerListPingEvent
public 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 @NotNull 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 @NotNull String getVersion()
public void setVersion(@NotNull @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 @Nullable CachedServerIcon getServerIcon()
null
for nonepublic void setServerIcon(@Nullable @Nullable CachedServerIcon icon)
setServerIcon
in class ServerListPingEvent
icon
- 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 Cancellable
public 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 Cancellable
cancel
- true if you wish to cancel this event@NotNull public @NotNull 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
Copyright © 2021. All rights reserved.