mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 04:17:44 +01:00
#759: Add preview chat option in ServerListPingEvent
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
3cdd9f03ce
commit
1a5ff83244
@ -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 int MAGIC_PLAYER_COUNT = Integer.MIN_VALUE;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final InetAddress address;
|
private final InetAddress address;
|
||||||
|
private final boolean shouldSendChatPreviews;
|
||||||
private String motd;
|
private String motd;
|
||||||
private final int numPlayers;
|
private final int numPlayers;
|
||||||
private int maxPlayers;
|
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);
|
super(true);
|
||||||
Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
|
Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.motd = motd;
|
this.motd = motd;
|
||||||
|
this.shouldSendChatPreviews = shouldSendChatPreviews;
|
||||||
this.numPlayers = numPlayers;
|
this.numPlayers = numPlayers;
|
||||||
this.maxPlayers = maxPlayers;
|
this.maxPlayers = maxPlayers;
|
||||||
}
|
}
|
||||||
@ -41,13 +43,15 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
|||||||
*
|
*
|
||||||
* @param address the address of the pinger
|
* @param address the address of the pinger
|
||||||
* @param motd the message of the day
|
* @param motd the message of the day
|
||||||
|
* @param shouldSendChatPreviews if the server should send chat previews
|
||||||
* @param maxPlayers the max number of players
|
* @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);
|
super(true);
|
||||||
this.numPlayers = MAGIC_PLAYER_COUNT;
|
this.numPlayers = MAGIC_PLAYER_COUNT;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.motd = motd;
|
this.motd = motd;
|
||||||
|
this.shouldSendChatPreviews = shouldSendChatPreviews;
|
||||||
this.maxPlayers = maxPlayers;
|
this.maxPlayers = maxPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +109,16 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
|||||||
return maxPlayers;
|
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.
|
* Set the maximum number of players sent.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user