mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-09-18 21:45:12 +00:00
#759: Add preview chat option in ServerListPingEvent
This commit is contained in:
parent
0169e65d2a
commit
57849c1b50
1 changed files with 16 additions and 2 deletions
|
@ -21,15 +21,17 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
|||
private static final int MAGIC_PLAYER_COUNT = Integer.MIN_VALUE;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final InetAddress address;
|
||||
private final boolean shouldSendChatPreviews;
|
||||
private String motd;
|
||||
private final int numPlayers;
|
||||
private int maxPlayers;
|
||||
|
||||
public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int numPlayers, final int maxPlayers) {
|
||||
public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final boolean shouldSendChatPreviews, final int numPlayers, final int maxPlayers) {
|
||||
super(true);
|
||||
Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
|
||||
this.address = address;
|
||||
this.motd = motd;
|
||||
this.shouldSendChatPreviews = shouldSendChatPreviews;
|
||||
this.numPlayers = numPlayers;
|
||||
this.maxPlayers = maxPlayers;
|
||||
}
|
||||
|
@ -41,13 +43,15 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
|||
*
|
||||
* @param address the address of the pinger
|
||||
* @param motd the message of the day
|
||||
* @param shouldSendChatPreviews if the server should send chat previews
|
||||
* @param maxPlayers the max number of players
|
||||
*/
|
||||
protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int maxPlayers) {
|
||||
protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, boolean shouldSendChatPreviews, final int maxPlayers) {
|
||||
super(true);
|
||||
this.numPlayers = MAGIC_PLAYER_COUNT;
|
||||
this.address = address;
|
||||
this.motd = motd;
|
||||
this.shouldSendChatPreviews = shouldSendChatPreviews;
|
||||
this.maxPlayers = maxPlayers;
|
||||
}
|
||||
|
||||
|
@ -105,6 +109,16 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
|||
return maxPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the server needs to send a preview of the chat to the
|
||||
* client.
|
||||
*
|
||||
* @return true if chat preview is enabled, false otherwise
|
||||
*/
|
||||
public boolean shouldSendChatPreviews() {
|
||||
return shouldSendChatPreviews;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum number of players sent.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue