3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Allow making the "players" response null.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-08-25 10:59:42 -04:00
Ursprung c1b1e71075
Commit d0ecc2b623

Datei anzeigen

@ -18,9 +18,9 @@ public class ServerPing {
private final Component description;
private final @Nullable Favicon favicon;
public ServerPing(@NonNull Version version, @NonNull Players players, @NonNull Component description, @Nullable Favicon favicon) {
public ServerPing(Version version, @Nullable Players players, Component description, @Nullable Favicon favicon) {
this.version = Preconditions.checkNotNull(version, "version");
this.players = Preconditions.checkNotNull(players, "players");
this.players = players;
this.description = Preconditions.checkNotNull(description, "description");
this.favicon = favicon;
}
@ -29,8 +29,8 @@ public class ServerPing {
return version;
}
public Players getPlayers() {
return players;
public Optional<Players> getPlayers() {
return Optional.ofNullable(players);
}
public Component getDescription() {
@ -76,6 +76,7 @@ public class ServerPing {
private final List<SamplePlayer> samplePlayers = new ArrayList<>();
private Component description;
private Favicon favicon;
private boolean nullOutPlayers;
private Builder() {
@ -106,6 +107,11 @@ public class ServerPing {
return this;
}
public Builder nullPlayers() {
this.nullOutPlayers = true;
return this;
}
public Builder description(Component description) {
this.description = Preconditions.checkNotNull(description, "description");
return this;
@ -117,7 +123,7 @@ public class ServerPing {
}
public ServerPing build() {
return new ServerPing(version, new Players(onlinePlayers, maximumPlayers, samplePlayers), description, favicon);
return new ServerPing(version, nullOutPlayers ? null : new Players(onlinePlayers, maximumPlayers, samplePlayers), description, favicon);
}
public Version getVersion() {