Fixed sending ServerData packets if the description component from the backend server is null (#1673)
This commit is contained in:
@@ -19,7 +19,9 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a 1.7 and above server list ping response. This class is immutable.
|
||||
@@ -28,7 +30,7 @@ public final class ServerPing {
|
||||
|
||||
private final Version version;
|
||||
private final @Nullable Players players;
|
||||
private final net.kyori.adventure.text.Component description;
|
||||
private final @Nullable Component description;
|
||||
private final @Nullable Favicon favicon;
|
||||
private final @Nullable ModInfo modinfo;
|
||||
|
||||
@@ -47,8 +49,8 @@ public final class ServerPing {
|
||||
* @param modinfo the mods this server runs
|
||||
*/
|
||||
public ServerPing(Version version, @Nullable Players players,
|
||||
net.kyori.adventure.text.Component description, @Nullable Favicon favicon,
|
||||
@Nullable ModInfo modinfo) {
|
||||
Component description, @Nullable Favicon favicon,
|
||||
@Nullable ModInfo modinfo) {
|
||||
this.version = Preconditions.checkNotNull(version, "version");
|
||||
this.players = players;
|
||||
this.description = Preconditions.checkNotNull(description, "description");
|
||||
@@ -64,7 +66,8 @@ public final class ServerPing {
|
||||
return Optional.ofNullable(players);
|
||||
}
|
||||
|
||||
public net.kyori.adventure.text.Component getDescriptionComponent() {
|
||||
@Nullable
|
||||
public Component getDescriptionComponent() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@@ -151,7 +154,7 @@ public final class ServerPing {
|
||||
private final List<SamplePlayer> samplePlayers = new ArrayList<>();
|
||||
private String modType = "FML";
|
||||
private final List<ModInfo.Mod> mods = new ArrayList<>();
|
||||
private net.kyori.adventure.text.Component description;
|
||||
private Component description;
|
||||
private @Nullable Favicon favicon;
|
||||
private boolean nullOutPlayers;
|
||||
private boolean nullOutModinfo;
|
||||
@@ -299,7 +302,7 @@ public final class ServerPing {
|
||||
* @param description Component to use as the description.
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder description(net.kyori.adventure.text.Component description) {
|
||||
public Builder description(Component description) {
|
||||
this.description = Preconditions.checkNotNull(description, "description");
|
||||
return this;
|
||||
}
|
||||
@@ -359,7 +362,7 @@ public final class ServerPing {
|
||||
return samplePlayers;
|
||||
}
|
||||
|
||||
public Optional<net.kyori.adventure.text.Component> getDescriptionComponent() {
|
||||
public Optional<Component> getDescriptionComponent() {
|
||||
return Optional.ofNullable(description);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user