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

Fixed most Checkstyle warnings in the API.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-10-28 00:41:21 -04:00
Ursprung 25b5e00125
Commit 6467335f74
37 geänderte Dateien mit 373 neuen und 275 gelöschten Zeilen

Datei anzeigen

@ -57,8 +57,8 @@ public class PluginAnnotationProcessor extends AbstractProcessor {
if (Objects.equals(pluginClassFound, qualifiedName.toString())) {
if (!warnedAboutMultiplePlugins) {
environment.getMessager()
.printMessage(Diagnostic.Kind.WARNING, "Velocity does not yet currently support " +
"multiple plugins. We are using " + pluginClassFound
.printMessage(Diagnostic.Kind.WARNING, "Velocity does not yet currently support "
+ "multiple plugins. We are using " + pluginClassFound
+ " for your plugin's main class.");
warnedAboutMultiplePlugins = true;
}
@ -69,8 +69,8 @@ public class PluginAnnotationProcessor extends AbstractProcessor {
if (!PluginDescription.ID_PATTERN.matcher(plugin.id()).matches()) {
environment.getMessager().printMessage(Diagnostic.Kind.ERROR, "Invalid ID for plugin "
+ qualifiedName
+ ". IDs must start alphabetically, have alphanumeric characters, and can " +
"contain dashes or underscores.");
+ ". IDs must start alphabetically, have alphanumeric characters, and can "
+ "contain dashes or underscores.");
return false;
}

Datei anzeigen

@ -23,7 +23,7 @@ public class SerializedPluginDescription {
private final @Nullable List<Dependency> dependencies;
private final String main;
public SerializedPluginDescription(String id, String name, String version, String description,
private SerializedPluginDescription(String id, String name, String version, String description,
String url,
List<String> authors, List<Dependency> dependencies, String main) {
this.id = Preconditions.checkNotNull(id, "id");
@ -37,7 +37,7 @@ public class SerializedPluginDescription {
this.main = Preconditions.checkNotNull(main, "main");
}
public static SerializedPluginDescription from(Plugin plugin, String qualifiedName) {
static SerializedPluginDescription from(Plugin plugin, String qualifiedName) {
List<Dependency> dependencies = new ArrayList<>();
for (com.velocitypowered.api.plugin.Dependency dependency : plugin.dependencies()) {
dependencies.add(new Dependency(dependency.id(), dependency.optional()));
@ -89,14 +89,14 @@ public class SerializedPluginDescription {
return false;
}
SerializedPluginDescription that = (SerializedPluginDescription) o;
return Objects.equals(id, that.id) &&
Objects.equals(name, that.name) &&
Objects.equals(version, that.version) &&
Objects.equals(description, that.description) &&
Objects.equals(url, that.url) &&
Objects.equals(authors, that.authors) &&
Objects.equals(dependencies, that.dependencies) &&
Objects.equals(main, that.main);
return Objects.equals(id, that.id)
&& Objects.equals(name, that.name)
&& Objects.equals(version, that.version)
&& Objects.equals(description, that.description)
&& Objects.equals(url, that.url)
&& Objects.equals(authors, that.authors)
&& Objects.equals(dependencies, that.dependencies)
&& Objects.equals(main, that.main);
}
@Override
@ -106,16 +106,16 @@ public class SerializedPluginDescription {
@Override
public String toString() {
return "SerializedPluginDescription{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", version='" + version + '\'' +
", description='" + description + '\'' +
", url='" + url + '\'' +
", authors=" + authors +
", dependencies=" + dependencies +
", main='" + main + '\'' +
'}';
return "SerializedPluginDescription{"
+ "id='" + id + '\''
+ ", name='" + name + '\''
+ ", version='" + version + '\''
+ ", description='" + description + '\''
+ ", url='" + url + '\''
+ ", authors=" + authors
+ ", dependencies=" + dependencies
+ ", main='" + main + '\''
+ '}';
}
public static class Dependency {
@ -145,8 +145,8 @@ public class SerializedPluginDescription {
return false;
}
Dependency that = (Dependency) o;
return optional == that.optional &&
Objects.equals(id, that.id);
return optional == that.optional
&& Objects.equals(id, that.id);
}
@Override
@ -156,10 +156,10 @@ public class SerializedPluginDescription {
@Override
public String toString() {
return "Dependency{" +
"id='" + id + '\'' +
", optional=" + optional +
'}';
return "Dependency{"
+ "id='" + id + '\''
+ ", optional=" + optional
+ '}';
}
}
}

Datei anzeigen

@ -20,8 +20,8 @@ public final class ConnectionHandshakeEvent {
@Override
public String toString() {
return "ConnectionHandshakeEvent{" +
"connection=" + connection +
'}';
return "ConnectionHandshakeEvent{"
+ "connection=" + connection
+ '}';
}
}

Datei anzeigen

@ -21,8 +21,8 @@ public final class DisconnectEvent {
@Override
public String toString() {
return "DisconnectEvent{" +
"player=" + player +
'}';
return "DisconnectEvent{"
+ "player=" + player
+ '}';
}
}

Datei anzeigen

@ -34,9 +34,9 @@ public final class LoginEvent implements ResultedEvent<ResultedEvent.ComponentRe
@Override
public String toString() {
return "LoginEvent{" +
"player=" + player +
", result=" + result +
'}';
return "LoginEvent{"
+ "player=" + player
+ ", result=" + result
+ '}';
}
}

Datei anzeigen

@ -4,6 +4,8 @@ import com.google.common.base.Preconditions;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
@ -11,7 +13,7 @@ import java.util.Arrays;
/**
* This event is fired when a plugin message is sent to the proxy, either from a client ({@link
* com.velocitypowered.api.proxy.Player}) or a server ({@link com.velocitypowered.api.proxy.ServerConnection}).
* Player}) or a server ({@link ServerConnection}).
*/
public final class PluginMessageEvent implements ResultedEvent<PluginMessageEvent.ForwardResult> {
@ -21,6 +23,14 @@ public final class PluginMessageEvent implements ResultedEvent<PluginMessageEven
private final byte[] data;
private ForwardResult result;
/**
* Creates a new instance.
*
* @param source the source of the plugin message
* @param target the destination of the plugin message
* @param identifier the channel for this plugin message
* @param data the payload of the plugin message
*/
public PluginMessageEvent(ChannelMessageSource source, ChannelMessageSink target,
ChannelIdentifier identifier, byte[] data) {
this.source = Preconditions.checkNotNull(source, "source");
@ -62,13 +72,13 @@ public final class PluginMessageEvent implements ResultedEvent<PluginMessageEven
@Override
public String toString() {
return "PluginMessageEvent{" +
"source=" + source +
", target=" + target +
", identifier=" + identifier +
", data=" + Arrays.toString(data) +
", result=" + result +
'}';
return "PluginMessageEvent{"
+ "source=" + source
+ ", target=" + target
+ ", identifier=" + identifier
+ ", data=" + Arrays.toString(data)
+ ", result=" + result
+ '}';
}
/**

Datei anzeigen

@ -4,8 +4,8 @@ import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
/**
* This event is fired once the player has been successfully authenticated and fully initialized and
* player will be connected to server after this event
* This event is fired once the player has been fully initialized and is about to connect to their
* first server.
*/
public final class PostLoginEvent {

Datei anzeigen

@ -19,6 +19,11 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
private final String username;
private PreLoginComponentResult result;
/**
* Creates a new instance.
* @param connection the connection logging into the proxy
* @param username the player's username
*/
public PreLoginEvent(InboundConnection connection, String username) {
this.connection = Preconditions.checkNotNull(connection, "connection");
this.username = Preconditions.checkNotNull(username, "username");
@ -45,11 +50,11 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
@Override
public String toString() {
return "PreLoginEvent{" +
"connection=" + connection +
", username='" + username + '\'' +
", result=" + result +
'}';
return "PreLoginEvent{"
+ "connection=" + connection
+ ", username='" + username + '\''
+ ", result=" + result
+ '}';
}
/**
@ -126,7 +131,7 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
/**
* Returns a result indicating the connection will be allowed through the proxy, but the
* connection will be forced to use offline mode even when proxy running in online mode
* connection will be forced to use offline mode even when the proxy is running in online mode.
*
* @return the result
*/

Datei anzeigen

@ -54,10 +54,10 @@ public final class PermissionsSetupEvent {
@Override
public String toString() {
return "PermissionsSetupEvent{" +
"subject=" + subject +
", defaultProvider=" + defaultProvider +
", provider=" + provider +
'}';
return "PermissionsSetupEvent{"
+ "subject=" + subject
+ ", defaultProvider=" + defaultProvider
+ ", provider=" + provider
+ '}';
}
}

Datei anzeigen

@ -18,6 +18,12 @@ public final class GameProfileRequestEvent {
private final boolean onlineMode;
private @Nullable GameProfile gameProfile;
/**
* Creates a new instance.
* @param connection the connection connecting to the proxy
* @param originalProfile the original {@link GameProfile} for the user
* @param onlineMode whether or not the user connected in online or offline mode
*/
public GameProfileRequestEvent(InboundConnection connection, GameProfile originalProfile,
boolean onlineMode) {
this.connection = Preconditions.checkNotNull(connection, "connection");
@ -57,21 +63,19 @@ public final class GameProfileRequestEvent {
* Sets the game profile to use for this connection. It is invalid to use this method on an
* online-mode connection.
*
* @param gameProfile the profile to use for the connection, {@code null} uses the original
* profile
* @param gameProfile the profile for this connection, {@code null} uses the original profile
*/
public void setGameProfile(@Nullable GameProfile gameProfile) {
Preconditions
.checkState(!onlineMode, "Connection is in online mode, profiles can not be faked");
Preconditions.checkState(!onlineMode, "Profiles can not be faked in online mode!");
this.gameProfile = gameProfile;
}
@Override
public String toString() {
return "GameProfileRequestEvent{" +
"username=" + username +
", gameProfile=" + gameProfile +
"}";
return "GameProfileRequestEvent{"
+ "username=" + username
+ ", gameProfile=" + gameProfile
+ "}";
}

Datei anzeigen

@ -42,11 +42,11 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
@Override
public String toString() {
return "PlayerChatEvent{" +
"player=" + player +
", message=" + message +
", result=" + result +
'}';
return "PlayerChatEvent{"
+ "player=" + player
+ ", message=" + message
+ ", result=" + result
+ '}';
}
/**

Datei anzeigen

@ -1,5 +1,6 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.util.ModInfo;
@ -24,4 +25,12 @@ public final class PlayerModInfoEvent {
public ModInfo getModInfo() {
return modInfo;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("player", player)
.add("modInfo", modInfo)
.toString();
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package com.velocitypowered.api.event.player;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.player.PlayerSettings;
@ -21,4 +22,12 @@ public final class PlayerSettingsChangedEvent {
public PlayerSettings getPlayerSettings() {
return playerSettings;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("player", player)
.add("playerSettings", playerSettings)
.toString();
}
}

Datei anzeigen

@ -28,9 +28,9 @@ public final class ServerConnectedEvent {
@Override
public String toString() {
return "ServerConnectedEvent{" +
"player=" + player +
", server=" + server +
'}';
return "ServerConnectedEvent{"
+ "player=" + player
+ ", server=" + server
+ '}';
}
}

Datei anzeigen

@ -43,11 +43,11 @@ public final class ServerPreConnectEvent implements
@Override
public String toString() {
return "ServerPreConnectEvent{" +
"player=" + player +
", originalServer=" + originalServer +
", result=" + result +
'}';
return "ServerPreConnectEvent{"
+ "player=" + player
+ ", originalServer=" + originalServer
+ ", result=" + result
+ '}';
}
/**

Datei anzeigen

@ -31,9 +31,9 @@ public final class ProxyPingEvent {
@Override
public String toString() {
return "ProxyPingEvent{" +
"connection=" + connection +
", ping=" + ping +
'}';
return "ProxyPingEvent{"
+ "connection=" + connection
+ ", ping=" + ping
+ '}';
}
}

Datei anzeigen

@ -6,7 +6,7 @@ import java.net.InetAddress;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* This event is fired if proxy is getting queried over GS4 Query protocol
* This event is fired if proxy is getting queried over GS4 Query protocol.
*/
public final class ProxyQueryEvent {
@ -14,6 +14,13 @@ public final class ProxyQueryEvent {
private final InetAddress querierAddress;
private QueryResponse response;
/**
* Creates a new event.
*
* @param queryType the type of query
* @param querierAddress the remote address for the query
* @param response the current query response
*/
public ProxyQueryEvent(QueryType queryType, InetAddress querierAddress, QueryResponse response) {
this.queryType = Preconditions.checkNotNull(queryType, "queryType");
this.querierAddress = Preconditions.checkNotNull(querierAddress, "querierAddress");
@ -21,7 +28,7 @@ public final class ProxyQueryEvent {
}
/**
* Get query type
* Returns the kind of query the remote client is performing.
*
* @return query type
*/
@ -31,7 +38,7 @@ public final class ProxyQueryEvent {
}
/**
* Get querier address
* Get the address of the client that sent this query.
*
* @return querier address
*/
@ -41,9 +48,9 @@ public final class ProxyQueryEvent {
}
/**
* Get query response
* Returns the current query response.
*
* @return query response
* @return the current query response
*/
@NonNull
public QueryResponse getResponse() {
@ -51,9 +58,9 @@ public final class ProxyQueryEvent {
}
/**
* Set query response
* Sets a new query response.
*
* @param response query response
* @param response the new non-null query response
*/
public void setResponse(@NonNull QueryResponse response) {
this.response = Preconditions.checkNotNull(response, "response");
@ -61,20 +68,20 @@ public final class ProxyQueryEvent {
@Override
public String toString() {
return "ProxyQueryEvent{" +
"queryType=" + queryType +
", querierAddress=" + querierAddress +
", response=" + response +
'}';
return "ProxyQueryEvent{"
+ "queryType=" + queryType
+ ", querierAddress=" + querierAddress
+ ", response=" + response
+ '}';
}
/**
* The type of query
* Represents the type of query the client is asking for.
*/
public enum QueryType {
/**
* Basic query asks only a subset of information, such as hostname, game type (hardcoded to
* <pre>MINECRAFT</pre>), map, current players, max players, proxy port and proxy hostname
* <pre>MINECRAFT</pre>), map, current players, max players, proxy port and proxy hostname.
*/
BASIC,
@ -82,6 +89,6 @@ public final class ProxyQueryEvent {
* Full query asks pretty much everything present on this event (only hardcoded values cannot be
* modified here).
*/
FULL;
FULL
}
}

Datei anzeigen

@ -16,22 +16,22 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public enum Tristate {
/**
* A value indicating a positive setting
* A value indicating a positive setting.
*/
TRUE(true),
/**
* A value indicating a negative (negated) setting
* A value indicating a negative (negated) setting.
*/
FALSE(false),
/**
* A value indicating a non-existent setting
* A value indicating a non-existent setting.
*/
UNDEFINED(false);
/**
* Returns a {@link Tristate} from a boolean
* Returns a {@link Tristate} from a boolean.
*
* @param val the boolean value
* @return {@link #TRUE} or {@link #FALSE}, if the value is <code>true</code> or

Datei anzeigen

@ -5,7 +5,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Represents a dependency for a {@link Plugin}
* Indicates that the {@link Plugin} depends on another plugin in order to enable.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({})
@ -20,9 +20,10 @@ public @interface Dependency {
String id();
/**
* If this dependency is optional for the plugin to work. By default this is {@code false}.
* Whether or not the dependency is not required to enable this plugin. By default this is
* {@code false}, meaning that the dependency is required to enable this plugin.
*
* @return true if the dependency is optional for the plugin to work
* @return true if the dependency is not required for the plugin to work
*/
boolean optional() default false;
}

Datei anzeigen

@ -13,9 +13,8 @@ import java.lang.annotation.Target;
public @interface Plugin {
/**
* The ID of the plugin. This ID should be unique as to not conflict with other plugins.
*
* The plugin ID must match the {@link PluginDescription#ID_PATTERN}.
* The ID of the plugin. This ID should be unique as to not conflict with other plugins. The
* plugin ID must match the {@link PluginDescription#ID_PATTERN}.
*
* @return the ID for this plugin
*/

Datei anzeigen

@ -19,6 +19,12 @@ public final class PluginDependency {
private final boolean optional;
/**
* Creates a new instance.
* @param id the plugin ID
* @param version an optional version
* @param optional whether or not this dependency is optional
*/
public PluginDependency(String id, @Nullable String version, boolean optional) {
this.id = checkNotNull(id, "id");
checkArgument(!id.isEmpty(), "id cannot be empty");
@ -27,7 +33,7 @@ public final class PluginDependency {
}
/**
* Returns the plugin ID of this {@link PluginDependency}
* Returns the plugin ID of this {@link PluginDependency}.
*
* @return the plugin ID
*/
@ -62,9 +68,9 @@ public final class PluginDependency {
return false;
}
PluginDependency that = (PluginDependency) o;
return optional == that.optional &&
Objects.equals(id, that.id) &&
Objects.equals(version, that.version);
return optional == that.optional
&& Objects.equals(id, that.id)
&& Objects.equals(version, that.version);
}
@Override
@ -74,10 +80,10 @@ public final class PluginDependency {
@Override
public String toString() {
return "PluginDependency{" +
"id='" + id + '\'' +
", version='" + version + '\'' +
", optional=" + optional +
'}';
return "PluginDependency{"
+ "id='" + id + '\''
+ ", version='" + version + '\''
+ ", optional=" + optional
+ '}';
}
}

Datei anzeigen

@ -6,8 +6,8 @@ import java.util.concurrent.CompletableFuture;
import net.kyori.text.Component;
/**
* Provides a fluent interface to compose and send a connection request to another server behind the
* proxy. A connection request is created using {@link Player#createConnectionRequest(RegisteredServer)}.
* Provides a fluent interface to send a connection request to another server on the proxy. A
* connection request is created using {@link Player#createConnectionRequest(RegisteredServer)}.
*/
public interface ConnectionRequestBuilder {

Datei anzeigen

@ -43,7 +43,7 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage
Optional<ServerConnection> getCurrentServer();
/**
* Returns the player settings
* Returns the player's client settings.
*
* @return the settings
*/
@ -57,7 +57,7 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage
Optional<ModInfo> getModInfo();
/**
* Returns the current player's ping
* Returns the current player's ping.
*
* @return the player's ping or -1 if ping information is currently unknown
*/

Datei anzeigen

@ -1,5 +1,6 @@
package com.velocitypowered.api.proxy.config;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.util.Favicon;
import java.util.List;
import java.util.Map;
@ -7,54 +8,54 @@ import java.util.Optional;
import net.kyori.text.Component;
/**
* Provides an interface to a proxy configuration
* Exposes certain proxy configuration information that plugins may use.
*/
public interface ProxyConfig {
/**
* Whether GameSpy 4 queries are accepted by the proxy
* Whether GameSpy 4 queries are accepted by the proxy.
*
* @return queries enabled
*/
boolean isQueryEnabled();
/**
* Get the port GameSpy 4 queries are accepted on
* Get the port GameSpy 4 queries are accepted on.
*
* @return the query port
*/
int getQueryPort();
/**
* Get the map name reported to GameSpy 4 query services
* Get the map name reported to GameSpy 4 query services.
*
* @return the map name
*/
String getQueryMap();
/**
* Whether GameSpy 4 queries should show plugins installed on Velocity by default
* Whether GameSpy 4 queries should show plugins installed on Velocity by default.
*
* @return show plugins in query
*/
boolean shouldQueryShowPlugins();
/**
* Get the MOTD component shown in the tab list
* Get the MOTD component shown in the tab list.
*
* @return the motd component
*/
Component getMotdComponent();
/**
* Get the maximum players shown in the tab list
* Get the maximum players shown in the tab list.
*
* @return max players
*/
int getShowMaxPlayers();
/**
* Get whether the proxy is online mode. This determines if players are authenticated with Mojang
* Get whether the proxy is online mode. This determines if players are authenticated with Mojang.
* servers.
*
* @return online mode enabled
@ -62,70 +63,72 @@ public interface ProxyConfig {
boolean isOnlineMode();
/**
* Get a Map of all servers registered on this proxy
* Get a Map of all servers registered in <code>velocity.toml</code>. This method does
* <strong>not</strong> return all the servers currently in memory, although in most cases it
* does. For a view of all registered servers, see {@link ProxyServer#getAllServers()}.
*
* @return registered servers map
*/
Map<String, String> getServers();
/**
* Get the order of servers that players will be connected to
* Get the order of servers that players will be connected to.
*
* @return connection order list
*/
List<String> getAttemptConnectionOrder();
/**
* Get forced servers mapped to given virtual host
* Get forced servers mapped to a given virtual host.
*
* @return list of server names
*/
Map<String, List<String>> getForcedHosts();
/**
* Get the minimum compression threshold for packets
* Get the minimum compression threshold for packets.
*
* @return the compression threshold
*/
int getCompressionThreshold();
/**
* Get the level of compression that packets will be compressed to
* Get the level of compression that packets will be compressed to.
*
* @return the compression level
*/
int getCompressionLevel();
/**
* Get the limit for how long a player must wait to log back in
* Get the limit for how long a player must wait to log back in.
*
* @return the login rate limit (in milliseconds)
*/
int getLoginRatelimit();
/**
* Get the proxy favicon shown in the tablist
* Get the proxy favicon shown in the tablist.
*
* @return optional favicon
*/
Optional<Favicon> getFavicon();
/**
* Get whether this proxy displays that it supports Forge/FML
* Get whether this proxy displays that it supports Forge/FML.
*
* @return forge announce enabled
*/
boolean isAnnounceForge();
/**
* Get how long this proxy will wait until performing a read timeout
* Get how long this proxy will wait for a connection to be established before timing it out.
*
* @return connection timeout (in milliseconds)
*/
int getConnectTimeout();
/**
* Get how long this proxy will wait until performing a read timeout
* Get how long this proxy will wait until performing a read timeout.
*
* @return read timeout (in milliseconds)
*/

Datei anzeigen

@ -1,7 +1,7 @@
package com.velocitypowered.api.proxy.messages;
/**
* Represents a kind of channel identifier.
* Represents a kind of channel identifier for use with plugin messaging.
*/
public interface ChannelIdentifier {

Datei anzeigen

@ -7,14 +7,15 @@ package com.velocitypowered.api.proxy.messages;
public interface ChannelRegistrar {
/**
* Registers the specified message identifiers to listen on for the
* Registers the specified message identifiers to listen on so you can intercept plugin messages
* on the channel using {@link com.velocitypowered.api.event.connection.PluginMessageEvent}.
*
* @param identifiers the channel identifiers to register
*/
void register(ChannelIdentifier... identifiers);
/**
* Unregisters the handler for the specified channel.
* Removes the intent to listen for the specified channel.
*
* @param identifiers the identifiers to unregister
*/

Datei anzeigen

@ -72,8 +72,8 @@ public final class MinecraftChannelIdentifier implements ChannelIdentifier {
return false;
}
MinecraftChannelIdentifier that = (MinecraftChannelIdentifier) o;
return Objects.equals(namespace, that.namespace) &&
Objects.equals(name, that.name);
return Objects.equals(namespace, that.namespace)
&& Objects.equals(name, that.name);
}
@Override

Datei anzeigen

@ -45,15 +45,16 @@ public interface TabListEntry {
/**
* Returns the latency for {@code this} entry.
* <p>The icon shown in the tab list is calculated by the latency in the following way:<p>
*
* <p>The icon shown in the tab list is calculated by the latency as follows:</p>
*
* <ul>
* <li>A negative latency will display the no connection icon</li>
* <li>0-150 will display 5 bars</li>
* <li>150-300 will display 4 bars</li>
* <li>300-600 will display 3 bars</li>
* <li>600-1000 will display 2 bars</li>
* <li>A latency move than 1 second will display 1 bar</li>
* <li></li>
* <li>A negative latency will display the no connection icon</li>
* <li>0-150 will display 5 bars</li>
* <li>150-300 will display 4 bars</li>
* <li>300-600 will display 3 bars</li>
* <li>600-1000 will display 2 bars</li>
* <li>A latency move than 1 second will display 1 bar</li>
* </ul>
*
* @return latency set for {@code this} entry
@ -61,7 +62,7 @@ public interface TabListEntry {
int getLatency();
/**
* Sets the latency for {@code this} entry to the specified value
* Sets the latency for {@code this} entry to the specified value.
*
* @param latency to changed to
* @return {@code this}, for chaining
@ -71,6 +72,7 @@ public interface TabListEntry {
/**
* Gets the game mode {@code this} entry has been set to.
*
* <p>The number corresponds to the game mode in the following way:</p>
* <ol start="0">
* <li>Survival</li>
@ -142,7 +144,7 @@ public interface TabListEntry {
}
/**
* Sets the displayed name of the {@link TabListEntry}
* Sets the displayed name of the {@link TabListEntry}.
*
* @param displayName to set
* @return {@code this}, for chaining
@ -154,7 +156,7 @@ public interface TabListEntry {
}
/**
* Sets the latency of the {@link TabListEntry}
* Sets the latency of the {@link TabListEntry}.
*
* @param latency to set
* @return {@code this}, for chaining
@ -166,7 +168,7 @@ public interface TabListEntry {
}
/**
* Sets the game mode of the {@link TabListEntry}
* Sets the game mode of the {@link TabListEntry}.
*
* @param gameMode to set
* @return {@code this}, for chaining

Datei anzeigen

@ -1,5 +1,6 @@
package com.velocitypowered.api.proxy.server;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.proxy.config.ProxyConfig;
@ -7,6 +8,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -90,7 +92,7 @@ public final class QueryResponse {
}
/**
* Get proxy (public facing) hostname
* Get proxy (public facing) hostname.
*
* @return proxy hostname
*/
@ -99,7 +101,7 @@ public final class QueryResponse {
}
/**
* Get proxy (public facing) port
* Get proxy (public facing) port.
*
* @return proxy port
*/
@ -136,7 +138,7 @@ 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
*/
@ -155,7 +157,7 @@ public final class QueryResponse {
}
/**
* Creates a new {@link Builder} instance
* Creates a new {@link Builder} instance.
*
* @return {@link QueryResponse} builder
*/
@ -225,6 +227,11 @@ public final class QueryResponse {
return this;
}
/**
* Sets the port where this proxy is running.
* @param proxyPort the port where the proxy is running
* @return this instance, for chaining
*/
public Builder proxyPort(int proxyPort) {
Preconditions
.checkArgument(proxyPort >= 1 && proxyPort <= 65535, "proxyPort must be between 1-65535");
@ -262,13 +269,19 @@ public final class QueryResponse {
return this;
}
/**
* Clears all currently set plugins.
*
* @return this builder, for chaining
*/
public Builder clearPlugins() {
this.plugins.clear();
return this;
}
/**
* Builds new {@link QueryResponse} with supplied data
* Builds a new {@link QueryResponse} with the supplied data. The current instance can be reused
* after this method is called.
*
* @return response
*/
@ -289,37 +302,36 @@ public final class QueryResponse {
}
/**
* Plugin information
* Represents a plugin in the query response.
*/
public static class PluginInformation {
private String name;
private String version;
private final String name;
private final @Nullable String version;
public PluginInformation(String name, String version) {
PluginInformation(String name, @Nullable String version) {
this.name = Preconditions.checkNotNull(name, "name");
this.version = Preconditions.checkNotNull(version, "version");
this.version = version;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setVersion(@Nullable String version) {
this.version = version;
}
@Nullable
public String getVersion() {
return version;
public Optional<String> getVersion() {
return Optional.ofNullable(version);
}
public static PluginInformation of(String name, @Nullable String version) {
return new PluginInformation(name, version);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("name", name)
.add("version", version)
.toString();
}
}
}

Datei anzeigen

@ -35,10 +35,10 @@ public final class ServerInfo {
@Override
public String toString() {
return "ServerInfo{" +
"name='" + name + '\'' +
", address=" + address +
'}';
return "ServerInfo{"
+ "name='" + name + '\''
+ ", address=" + address
+ '}';
}
@Override
@ -50,8 +50,8 @@ public final class ServerInfo {
return false;
}
ServerInfo that = (ServerInfo) o;
return Objects.equals(name, that.name) &&
Objects.equals(address, that.address);
return Objects.equals(name, that.name)
&& Objects.equals(address, that.address);
}
@Override

Datei anzeigen

@ -1,5 +1,6 @@
package com.velocitypowered.api.proxy.server;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.util.Favicon;
@ -59,14 +60,18 @@ public final class ServerPing {
@Override
public String toString() {
return "ServerPing{" +
"version=" + version +
", players=" + players +
", description=" + description +
", favicon='" + favicon + '\'' +
'}';
return "ServerPing{"
+ "version=" + version
+ ", players=" + players
+ ", description=" + description
+ ", favicon='" + favicon + '\''
+ '}';
}
/**
* Returns a copy of this {@link ServerPing} instance as a builder so that it can be modified.
* @return a copy of this instance as a {@link Builder}
*/
public Builder asBuilder() {
Builder builder = new Builder();
builder.version = version;
@ -171,6 +176,11 @@ public final class ServerPing {
return this;
}
/**
* Uses the information from this builder to create a new {@link ServerPing} instance. The
* builder can be re-used after this event has been called.
* @return a new {@link ServerPing} instance
*/
public ServerPing build() {
if (this.version == null) {
throw new IllegalStateException("version not specified");
@ -217,18 +227,18 @@ public final class ServerPing {
@Override
public String toString() {
return "Builder{" +
"version=" + version +
", onlinePlayers=" + onlinePlayers +
", maximumPlayers=" + maximumPlayers +
", samplePlayers=" + samplePlayers +
", modType=" + modType +
", mods=" + mods +
", description=" + description +
", favicon=" + favicon +
", nullOutPlayers=" + nullOutPlayers +
", nullOutModinfo=" + nullOutModinfo +
'}';
return MoreObjects.toStringHelper(this)
.add("version", version)
.add("onlinePlayers", onlinePlayers)
.add("maximumPlayers", maximumPlayers)
.add("samplePlayers", samplePlayers)
.add("modType", modType)
.add("mods", mods)
.add("description", description)
.add("favicon", favicon)
.add("nullOutPlayers", nullOutPlayers)
.add("nullOutModinfo", nullOutModinfo)
.toString();
}
}
@ -237,9 +247,14 @@ public final class ServerPing {
private final int protocol;
private final String name;
/**
* Creates a new instance.
* @param protocol the protocol version as an integer
* @param name a friendly name for the protocol version
*/
public Version(int protocol, String name) {
this.protocol = protocol;
this.name = name;
this.name = Preconditions.checkNotNull(name, "name");
}
public int getProtocol() {
@ -252,10 +267,10 @@ public final class ServerPing {
@Override
public String toString() {
return "Version{" +
"protocol=" + protocol +
", name='" + name + '\'' +
'}';
return "Version{"
+ "protocol=" + protocol
+ ", name='" + name + '\''
+ '}';
}
}
@ -265,6 +280,12 @@ public final class ServerPing {
private final int max;
private final List<SamplePlayer> sample;
/**
* Creates a new instance.
* @param online the number of online players
* @param max the maximum number of players
* @param sample a sample of players on the server
*/
public Players(int online, int max, List<SamplePlayer> sample) {
this.online = online;
this.max = max;
@ -285,11 +306,11 @@ public final class ServerPing {
@Override
public String toString() {
return "Players{" +
"online=" + online +
", max=" + max +
", sample=" + sample +
'}';
return "Players{"
+ "online=" + online
+ ", max=" + max
+ ", sample=" + sample
+ '}';
}
}
@ -313,10 +334,10 @@ public final class ServerPing {
@Override
public String toString() {
return "SamplePlayer{" +
"name='" + name + '\'' +
", id=" + id +
'}';
return "SamplePlayer{"
+ "name='" + name + '\''
+ ", id=" + id
+ '}';
}
}
}

Datei anzeigen

@ -59,9 +59,9 @@ public final class Favicon {
@Override
public String toString() {
return "Favicon{" +
"base64Url='" + base64Url + '\'' +
'}';
return "Favicon{"
+ "base64Url='" + base64Url + '\''
+ '}';
}
/**
@ -72,9 +72,8 @@ public final class Favicon {
*/
public static Favicon create(BufferedImage image) {
Preconditions.checkNotNull(image, "image");
Preconditions
.checkArgument(image.getWidth() == 64 && image.getHeight() == 64, "Image does not have" +
" 64x64 dimensions (found %sx%s)", image.getWidth(), image.getHeight());
Preconditions.checkArgument(image.getWidth() == 64 && image.getHeight() == 64,
"Image is not 64x64(found %sx%s)", image.getWidth(), image.getHeight());
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
ImageIO.write(image, "PNG", os);

Datei anzeigen

@ -50,11 +50,11 @@ public final class GameProfile {
@Override
public String toString() {
return "GameProfile{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", properties=" + properties +
'}';
return "GameProfile{"
+ "id='" + id + '\''
+ ", name='" + name + '\''
+ ", properties=" + properties
+ '}';
}
public static final class Property {
@ -83,11 +83,11 @@ public final class GameProfile {
@Override
public String toString() {
return "Property{" +
"name='" + name + '\'' +
", value='" + value + '\'' +
", signature='" + signature + '\'' +
'}';
return "Property{"
+ "name='" + name + '\''
+ ", value='" + value + '\''
+ ", signature='" + signature + '\''
+ '}';
}
}
}

Datei anzeigen

@ -26,10 +26,10 @@ public final class ModInfo {
@Override
public String toString() {
return "ModInfo{" +
"type='" + type + '\'' +
", modList=" + modList +
'}';
return "ModInfo{"
+ "type='" + type + '\''
+ ", modList=" + modList
+ '}';
}
public static final class Mod {
@ -52,10 +52,10 @@ public final class ModInfo {
@Override
public String toString() {
return "Mod{" +
"id='" + id + '\'' +
", version='" + version + '\'' +
'}';
return "Mod{"
+ "id='" + id + '\''
+ ", version='" + version + '\''
+ '}';
}
}
}

Datei anzeigen

@ -13,6 +13,13 @@ public final class ProxyVersion {
private final String vendor;
private final String version;
/**
* Creates a new {@link ProxyVersion} instance.
*
* @param name the name for the proxy implementation
* @param vendor the vendor for the proxy implementation
* @param version the version for the proxy implementation
*/
public ProxyVersion(String name, String vendor, String version) {
this.name = Preconditions.checkNotNull(name, "name");
this.vendor = Preconditions.checkNotNull(vendor, "vendor");
@ -40,9 +47,9 @@ public final class ProxyVersion {
return false;
}
ProxyVersion that = (ProxyVersion) o;
return Objects.equals(name, that.name) &&
Objects.equals(vendor, that.vendor) &&
Objects.equals(version, that.version);
return Objects.equals(name, that.name)
&& Objects.equals(vendor, that.vendor)
&& Objects.equals(version, that.version);
}
@Override
@ -52,10 +59,10 @@ public final class ProxyVersion {
@Override
public String toString() {
return "ProxyVersion{" +
"name='" + name + '\'' +
", vendor='" + vendor + '\'' +
", version='" + version + '\'' +
'}';
return "ProxyVersion{"
+ "name='" + name + '\''
+ ", vendor='" + vendor + '\''
+ ", version='" + version + '\''
+ '}';
}
}

Datei anzeigen

@ -38,8 +38,10 @@ public final class UuidUtils {
*/
public static String toUndashed(final UUID uuid) {
Preconditions.checkNotNull(uuid, "uuid");
return Strings.padStart(Long.toHexString(uuid.getMostSignificantBits()), 16, '0') +
Strings.padStart(Long.toHexString(uuid.getLeastSignificantBits()), 16, '0');
String msbStr = Long.toHexString(uuid.getMostSignificantBits());
String lsbStr = Long.toHexString(uuid.getLeastSignificantBits());
return Strings.padStart(msbStr, 16, '0') + Strings.padStart(lsbStr,
16, '0');
}
/**

Datei anzeigen

@ -1,5 +1,6 @@
package com.velocitypowered.api.util.title;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import java.util.Objects;
import java.util.Optional;
@ -110,24 +111,24 @@ public final class TextTitle implements Title {
return false;
}
TextTitle textTitle = (TextTitle) o;
return stay == textTitle.stay &&
fadeIn == textTitle.fadeIn &&
fadeOut == textTitle.fadeOut &&
resetBeforeSend == textTitle.resetBeforeSend &&
Objects.equals(title, textTitle.title) &&
Objects.equals(subtitle, textTitle.subtitle);
return stay == textTitle.stay
&& fadeIn == textTitle.fadeIn
&& fadeOut == textTitle.fadeOut
&& resetBeforeSend == textTitle.resetBeforeSend
&& Objects.equals(title, textTitle.title)
&& Objects.equals(subtitle, textTitle.subtitle);
}
@Override
public String toString() {
return "TextTitle{" +
"title=" + title +
", subtitle=" + subtitle +
", stay=" + stay +
", fadeIn=" + fadeIn +
", fadeOut=" + fadeOut +
", resetBeforeSend=" + resetBeforeSend +
'}';
return MoreObjects.toStringHelper(this)
.add("title", title)
.add("subtitle", subtitle)
.add("stay", stay)
.add("fadeIn", fadeIn)
.add("fadeOut", fadeOut)
.add("resetBeforeSend", resetBeforeSend)
.toString();
}
@Override
@ -238,14 +239,14 @@ public final class TextTitle implements Title {
@Override
public String toString() {
return "Builder{" +
"title=" + title +
", subtitle=" + subtitle +
", stay=" + stay +
", fadeIn=" + fadeIn +
", fadeOut=" + fadeOut +
", resetBeforeSend=" + resetBeforeSend +
'}';
return MoreObjects.toStringHelper(this)
.add("title", title)
.add("subtitle", subtitle)
.add("stay", stay)
.add("fadeIn", fadeIn)
.add("fadeOut", fadeOut)
.add("resetBeforeSend", resetBeforeSend)
.toString();
}
}
}