Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Adapt to upcoming Checker framework related changes
Dieser Commit ist enthalten in:
Ursprung
ea43b8ff60
Commit
447e7d1d50
@ -3,7 +3,7 @@ package com.velocitypowered.api.proxy.server;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.velocitypowered.api.proxy.config.ProxyConfig;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -43,7 +43,6 @@ public final class QueryResponse {
|
||||
* Get hostname which will be used to reply to the query. By default it is {@link ProxyConfig#getMotdComponent()} in plain text without colour codes.
|
||||
* @return hostname
|
||||
*/
|
||||
@NonNull
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
@ -52,7 +51,6 @@ public final class QueryResponse {
|
||||
* Get game version which will be used to reply to the query. By default supported Minecraft versions range is sent.
|
||||
* @return game version
|
||||
*/
|
||||
@NonNull
|
||||
public String getGameVersion() {
|
||||
return gameVersion;
|
||||
}
|
||||
@ -61,7 +59,6 @@ public final class QueryResponse {
|
||||
* Get map name which will be used to reply to the query. By default {@link ProxyConfig#getQueryMap()} is sent.
|
||||
* @return map name
|
||||
*/
|
||||
@NonNull
|
||||
public String getMap() {
|
||||
return map;
|
||||
}
|
||||
@ -86,7 +83,6 @@ public final class QueryResponse {
|
||||
* Get proxy (public facing) hostname
|
||||
* @return proxy hostname
|
||||
*/
|
||||
@NonNull
|
||||
public String getProxyHost() {
|
||||
return proxyHost;
|
||||
}
|
||||
@ -103,7 +99,6 @@ public final class QueryResponse {
|
||||
* Get collection of players which will be used to reply to the query.
|
||||
* @return collection of players
|
||||
*/
|
||||
@NonNull
|
||||
public Collection<String> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
@ -112,7 +107,6 @@ public final class QueryResponse {
|
||||
* Get server software (name and version) which will be used to reply to the query.
|
||||
* @return server software
|
||||
*/
|
||||
@NonNull
|
||||
public String getProxyVersion() {
|
||||
return proxyVersion;
|
||||
}
|
||||
@ -121,7 +115,6 @@ public final class QueryResponse {
|
||||
* Get list of plugins which will be used to reply to the query.
|
||||
* @return collection of plugins
|
||||
*/
|
||||
@NonNull
|
||||
public Collection<PluginInformation> getPlugins() {
|
||||
return plugins;
|
||||
}
|
||||
@ -131,7 +124,6 @@ public final class QueryResponse {
|
||||
* Creates a new {@link Builder} instance from data represented by this response
|
||||
* @return {@link QueryResponse} builder
|
||||
*/
|
||||
@NonNull
|
||||
public Builder toBuilder() {
|
||||
return QueryResponse.builder()
|
||||
.hostname(getHostname())
|
||||
@ -150,7 +142,6 @@ public final class QueryResponse {
|
||||
* Creates a new {@link Builder} instance
|
||||
* @return {@link QueryResponse} builder
|
||||
*/
|
||||
@NonNull
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
@ -159,101 +150,98 @@ public final class QueryResponse {
|
||||
* A builder for {@link QueryResponse} objects.
|
||||
*/
|
||||
public static final class Builder {
|
||||
@MonotonicNonNull
|
||||
private String hostname;
|
||||
|
||||
@MonotonicNonNull
|
||||
private String gameVersion;
|
||||
|
||||
@MonotonicNonNull
|
||||
private String map;
|
||||
|
||||
@MonotonicNonNull
|
||||
private String proxyHost;
|
||||
|
||||
@MonotonicNonNull
|
||||
private String proxyVersion;
|
||||
|
||||
private int currentPlayers;
|
||||
private int maxPlayers;
|
||||
private String proxyHost;
|
||||
private int proxyPort;
|
||||
private Collection<String> players = new ArrayList<>();
|
||||
private String proxyVersion;
|
||||
|
||||
private List<String> players = new ArrayList<>();
|
||||
private List<PluginInformation> plugins = new ArrayList<>();
|
||||
|
||||
private Builder() {}
|
||||
|
||||
@NonNull
|
||||
public Builder hostname(@NonNull String hostname) {
|
||||
public Builder hostname(String hostname) {
|
||||
this.hostname = Preconditions.checkNotNull(hostname, "hostname");
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder gameVersion(@NonNull String gameVersion) {
|
||||
public Builder gameVersion(String gameVersion) {
|
||||
this.gameVersion = Preconditions.checkNotNull(gameVersion, "gameVersion");
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder map(@NonNull String map) {
|
||||
public Builder map(String map) {
|
||||
this.map = Preconditions.checkNotNull(map, "map");
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder currentPlayers(int currentPlayers) {
|
||||
Preconditions.checkArgument(currentPlayers >= 0, "currentPlayers cannot be negative");
|
||||
this.currentPlayers = currentPlayers;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder maxPlayers(int maxPlayers) {
|
||||
Preconditions.checkArgument(maxPlayers >= 0, "maxPlayers cannot be negative");
|
||||
this.maxPlayers = maxPlayers;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder proxyHost(@NonNull String proxyHost) {
|
||||
public Builder proxyHost(String proxyHost) {
|
||||
this.proxyHost = Preconditions.checkNotNull(proxyHost, "proxyHost");
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder proxyPort(int proxyPort) {
|
||||
Preconditions.checkArgument(proxyPort >= 1 && proxyPort <= 65535, "proxyPort must be between 1-65535");
|
||||
this.proxyPort = proxyPort;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder players(@NonNull Collection<String> players) {
|
||||
public Builder players(Collection<String> players) {
|
||||
this.players.addAll(Preconditions.checkNotNull(players, "players"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder players(@NonNull String... players) {
|
||||
public Builder players(String... players) {
|
||||
this.players.addAll(Arrays.asList(Preconditions.checkNotNull(players, "players")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder clearPlayers() {
|
||||
this.players.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder proxyVersion(@NonNull String proxyVersion) {
|
||||
public Builder proxyVersion(String proxyVersion) {
|
||||
this.proxyVersion = Preconditions.checkNotNull(proxyVersion, "proxyVersion");
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder plugins(@NonNull Collection<PluginInformation> plugins) {
|
||||
public Builder plugins(Collection<PluginInformation> plugins) {
|
||||
this.plugins.addAll(Preconditions.checkNotNull(plugins, "plugins"));
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder plugins(@NonNull PluginInformation... plugins) {
|
||||
public Builder plugins(PluginInformation... plugins) {
|
||||
this.plugins.addAll(Arrays.asList(Preconditions.checkNotNull(plugins, "plugins")));
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder clearPlugins() {
|
||||
this.plugins.clear();
|
||||
return this;
|
||||
@ -263,18 +251,17 @@ public final class QueryResponse {
|
||||
* Builds new {@link QueryResponse} with supplied data
|
||||
* @return response
|
||||
*/
|
||||
@NonNull
|
||||
public QueryResponse build() {
|
||||
return new QueryResponse(
|
||||
hostname,
|
||||
gameVersion,
|
||||
map,
|
||||
Preconditions.checkNotNull(hostname, "hostname"),
|
||||
Preconditions.checkNotNull(gameVersion, "gameVersion"),
|
||||
Preconditions.checkNotNull(map, "map"),
|
||||
currentPlayers,
|
||||
maxPlayers,
|
||||
proxyHost,
|
||||
Preconditions.checkNotNull(proxyHost, "proxyHost"),
|
||||
proxyPort,
|
||||
ImmutableList.copyOf(players),
|
||||
proxyVersion,
|
||||
Preconditions.checkNotNull(proxyVersion, "proxyVersion"),
|
||||
ImmutableList.copyOf(plugins)
|
||||
);
|
||||
}
|
||||
@ -287,17 +274,16 @@ public final class QueryResponse {
|
||||
private String name;
|
||||
private String version;
|
||||
|
||||
public PluginInformation(@NonNull String name, @Nullable String version) {
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
public PluginInformation(String name, String version) {
|
||||
this.name = Preconditions.checkNotNull(name, "name");
|
||||
this.version = Preconditions.checkNotNull(version, "version");
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(@NonNull String name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ -310,8 +296,7 @@ public final class QueryResponse {
|
||||
return version;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static PluginInformation of(@NonNull String name, @Nullable String version) {
|
||||
public static PluginInformation of(String name, @Nullable String version) {
|
||||
return new PluginInformation(name, version);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import io.netty.channel.socket.DatagramPacket;
|
||||
import net.kyori.text.serializer.ComponentSerializers;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -56,6 +57,7 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
||||
.expireAfterWrite(30, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
@MonotonicNonNull
|
||||
private volatile List<QueryResponse.PluginInformation> pluginInformationList = null;
|
||||
|
||||
private final VelocityServer server;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren