13
0
geforkt von Mirrors/Velocity

Mark Velocity as a modded server on the server list

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-07 18:09:28 -04:00
Ursprung be9547612f
Commit 3eca6e9df1

Datei anzeigen

@ -4,7 +4,6 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.util.Favicon; import com.velocitypowered.api.util.Favicon;
import net.kyori.text.Component; import net.kyori.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.*; import java.util.*;
@ -17,12 +16,18 @@ public class ServerPing {
private final Players players; private final Players players;
private final Component description; private final Component description;
private final @Nullable Favicon favicon; private final @Nullable Favicon favicon;
private final Modinfo modinfo;
public ServerPing(Version version, @Nullable Players players, Component description, @Nullable Favicon favicon) { public ServerPing(Version version, @Nullable Players players, Component description, @Nullable Favicon favicon) {
this(version, players, description, favicon, Modinfo.DEFAULT);
}
public ServerPing(Version version, @Nullable Players players, Component description, @Nullable Favicon favicon, Modinfo modinfo) {
this.version = Preconditions.checkNotNull(version, "version"); this.version = Preconditions.checkNotNull(version, "version");
this.players = players; this.players = players;
this.description = Preconditions.checkNotNull(description, "description"); this.description = Preconditions.checkNotNull(description, "description");
this.favicon = favicon; this.favicon = favicon;
this.modinfo = modinfo;
} }
public Version getVersion() { public Version getVersion() {
@ -74,6 +79,7 @@ public class ServerPing {
private int onlinePlayers; private int onlinePlayers;
private int maximumPlayers; private int maximumPlayers;
private final List<SamplePlayer> samplePlayers = new ArrayList<>(); private final List<SamplePlayer> samplePlayers = new ArrayList<>();
private final List<Mod> mods = new ArrayList<>();
private Component description; private Component description;
private Favicon favicon; private Favicon favicon;
private boolean nullOutPlayers; private boolean nullOutPlayers;
@ -102,6 +108,16 @@ public class ServerPing {
return this; return this;
} }
public Builder mods(Mod... mods) {
this.mods.addAll(Arrays.asList(mods));
return this;
}
public Builder clearMods() {
this.mods.clear();
return this;
}
public Builder clearSamplePlayers() { public Builder clearSamplePlayers() {
this.samplePlayers.clear(); this.samplePlayers.clear();
return this; return this;
@ -123,7 +139,8 @@ public class ServerPing {
} }
public ServerPing build() { public ServerPing build() {
return new ServerPing(version, nullOutPlayers ? null : new Players(onlinePlayers, maximumPlayers, samplePlayers), description, favicon); return new ServerPing(version, nullOutPlayers ? null : new Players(onlinePlayers, maximumPlayers, samplePlayers), description, favicon,
new Modinfo(mods));
} }
public Version getVersion() { public Version getVersion() {
@ -150,6 +167,10 @@ public class ServerPing {
return favicon; return favicon;
} }
public List<Mod> getMods() {
return mods;
}
@Override @Override
public String toString() { public String toString() {
return "Builder{" + return "Builder{" +
@ -157,8 +178,10 @@ public class ServerPing {
", onlinePlayers=" + onlinePlayers + ", onlinePlayers=" + onlinePlayers +
", maximumPlayers=" + maximumPlayers + ", maximumPlayers=" + maximumPlayers +
", samplePlayers=" + samplePlayers + ", samplePlayers=" + samplePlayers +
", mods=" + mods +
", description=" + description + ", description=" + description +
", favicon=" + favicon + ", favicon=" + favicon +
", nullOutPlayers=" + nullOutPlayers +
'}'; '}';
} }
} }
@ -247,4 +270,25 @@ public class ServerPing {
'}'; '}';
} }
} }
public static class Modinfo {
public static final Modinfo DEFAULT = new Modinfo(ImmutableList.of());
private final String type = "FML";
private final List<Mod> modList;
public Modinfo(List<Mod> modList) {
this.modList = ImmutableList.copyOf(modList);
}
}
public static class Mod {
private final String id;
private final String version;
public Mod(String id, String version) {
this.id = Preconditions.checkNotNull(id, "id");
this.version = Preconditions.checkNotNull(version, "version");
}
}
} }