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