geforkt von Mirrors/Velocity
Add Javadoc and remove all Checkstyle issues from API and natives.
Dieser Commit ist enthalten in:
Ursprung
a4cdc4884a
Commit
868976e09c
@ -11,7 +11,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Fired when a player is kicked from a server. You may either allow Velocity to kick the player
|
||||
* (with an optional reason override) or redirect the player to a separate server.
|
||||
* (with an optional reason override) or redirect the player to a separate server. By default,
|
||||
* Velocity will notify the user (if they are already connected to a server) or disconnect them
|
||||
* (if they are not on a server and no other servers are available).
|
||||
*/
|
||||
public final class KickedFromServerEvent implements
|
||||
ResultedEvent<KickedFromServerEvent.ServerKickResult> {
|
||||
@ -22,6 +24,14 @@ public final class KickedFromServerEvent implements
|
||||
private final boolean duringServerConnect;
|
||||
private ServerKickResult result;
|
||||
|
||||
/**
|
||||
* Creates a {@code KickedFromServerEvent} instance.
|
||||
* @param player the player affected
|
||||
* @param server the server the player disconnected from
|
||||
* @param originalReason the reason for being kicked, optional
|
||||
* @param duringServerConnect whether or not the player was kicked during the connection process
|
||||
* @param fancyReason a fancy reason for being disconnected, used for the initial result
|
||||
*/
|
||||
public KickedFromServerEvent(Player player, RegisteredServer server,
|
||||
@Nullable Component originalReason, boolean duringServerConnect, Component fancyReason) {
|
||||
this.player = Preconditions.checkNotNull(player, "player");
|
||||
|
@ -16,6 +16,11 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
|
||||
private final String message;
|
||||
private ChatResult result;
|
||||
|
||||
/**
|
||||
* Constructs a PlayerChatEvent.
|
||||
* @param player the player sending the message
|
||||
* @param message the message being sent
|
||||
*/
|
||||
public PlayerChatEvent(Player player, String message) {
|
||||
this.player = Preconditions.checkNotNull(player, "player");
|
||||
this.message = Preconditions.checkNotNull(message, "message");
|
||||
@ -57,11 +62,10 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
|
||||
private static final ChatResult ALLOWED = new ChatResult(true, null);
|
||||
private static final ChatResult DENIED = new ChatResult(false, null);
|
||||
|
||||
// The server can not accept formatted text from clients!
|
||||
private @Nullable String message;
|
||||
private final boolean status;
|
||||
|
||||
protected ChatResult(boolean status, @Nullable String message) {
|
||||
private ChatResult(boolean status, @Nullable String message) {
|
||||
this.status = status;
|
||||
this.message = message;
|
||||
}
|
||||
@ -76,10 +80,18 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
|
||||
return status ? "allowed" : "denied";
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the message to be sent, without modification.
|
||||
* @return the allowed result
|
||||
*/
|
||||
public static ChatResult allowed() {
|
||||
return ALLOWED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents the message from being sent.
|
||||
* @return the denied result
|
||||
*/
|
||||
public static ChatResult denied() {
|
||||
return DENIED;
|
||||
}
|
||||
@ -88,6 +100,11 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
|
||||
return Optional.ofNullable(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the message to be sent, but silently replaced with another.
|
||||
* @param message the message to use instead
|
||||
* @return a result with a new message
|
||||
*/
|
||||
public static ChatResult message(@NonNull String message) {
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
return new ChatResult(true, message);
|
||||
|
@ -6,7 +6,7 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.util.ModInfo;
|
||||
|
||||
/**
|
||||
* This event is fired when the players ModInfo is changed.
|
||||
* This event is fired when a Forge client sends its mods to the proxy while connecting to a server.
|
||||
*/
|
||||
public final class PlayerModInfoEvent {
|
||||
|
||||
|
@ -2,6 +2,8 @@ package com.velocitypowered.api.event.player;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.event.ResultedEvent;
|
||||
import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
|
||||
import com.velocitypowered.api.proxy.ConnectionRequestBuilder.Status;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import java.util.Optional;
|
||||
@ -17,6 +19,11 @@ public final class ServerPreConnectEvent implements
|
||||
private final RegisteredServer originalServer;
|
||||
private ServerResult result;
|
||||
|
||||
/**
|
||||
* Creates the ServerPreConnectEvent.
|
||||
* @param player the player who is connecting to a server
|
||||
* @param originalServer the server the player was trying to connect to
|
||||
*/
|
||||
public ServerPreConnectEvent(Player player, RegisteredServer originalServer) {
|
||||
this.player = Preconditions.checkNotNull(player, "player");
|
||||
this.originalServer = Preconditions.checkNotNull(originalServer, "originalServer");
|
||||
@ -80,10 +87,21 @@ public final class ServerPreConnectEvent implements
|
||||
return "denied";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a result that will prevent players from connecting to another server. If this result
|
||||
* is used, then {@link ConnectionRequestBuilder#connect()}'s result will have the status
|
||||
* {@link Status#CONNECTION_CANCELLED}.
|
||||
* @return a result to deny conneections
|
||||
*/
|
||||
public static ServerResult denied() {
|
||||
return DENIED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the player to connect to the specified server.
|
||||
* @param server the new server to connect to
|
||||
* @return a result to allow the player to connect to the specified server
|
||||
*/
|
||||
public static ServerResult allowed(RegisteredServer server) {
|
||||
Preconditions.checkNotNull(server, "server");
|
||||
return new ServerResult(server);
|
||||
|
@ -50,7 +50,16 @@ public interface TabList {
|
||||
*/
|
||||
Collection<TabListEntry> getEntries();
|
||||
|
||||
// Necessary because the TabListEntry implementation isn't in the api
|
||||
/**
|
||||
* Builds a tab list entry.
|
||||
*
|
||||
* @deprecated Internal usage. Use {@link TabListEntry.Builder} instead.
|
||||
* @param profile profile
|
||||
* @param displayName display name
|
||||
* @param latency latency
|
||||
* @param gameMode game mode
|
||||
* @return entry
|
||||
*/
|
||||
@Deprecated
|
||||
TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
|
||||
int gameMode);
|
||||
|
@ -86,7 +86,7 @@ public interface TabListEntry {
|
||||
int getGameMode();
|
||||
|
||||
/**
|
||||
* Sets the game mode for {@code this} entry to the specified value
|
||||
* Sets the game mode for {@code this} entry to the specified value.
|
||||
*
|
||||
* @param gameMode to change to
|
||||
* @return {@code this}, for chaining
|
||||
|
@ -195,33 +195,63 @@ public final class QueryResponse {
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the hostname for the response.
|
||||
* @param hostname the hostname to set
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder hostname(String hostname) {
|
||||
this.hostname = Preconditions.checkNotNull(hostname, "hostname");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the game version for the response.
|
||||
* @param gameVersion the game version to set
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder gameVersion(String gameVersion) {
|
||||
this.gameVersion = Preconditions.checkNotNull(gameVersion, "gameVersion");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the map that will appear in the response.
|
||||
* @param map the map to set
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder map(String map) {
|
||||
this.map = Preconditions.checkNotNull(map, "map");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the players that are currently claimed to be online.
|
||||
* @param currentPlayers a non-negative number representing all players online
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder currentPlayers(int currentPlayers) {
|
||||
Preconditions.checkArgument(currentPlayers >= 0, "currentPlayers cannot be negative");
|
||||
this.currentPlayers = currentPlayers;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of players this server purportedly can hold.
|
||||
* @param maxPlayers a non-negative number representing the maximum number of builders
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder maxPlayers(int maxPlayers) {
|
||||
Preconditions.checkArgument(maxPlayers >= 0, "maxPlayers cannot be negative");
|
||||
this.maxPlayers = maxPlayers;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the host where this proxy is running.
|
||||
* @param proxyHost the host where the proxy is running
|
||||
* @return this instance, for chaining
|
||||
*/
|
||||
public Builder proxyHost(String proxyHost) {
|
||||
this.proxyHost = Preconditions.checkNotNull(proxyHost, "proxyHost");
|
||||
return this;
|
||||
@ -239,33 +269,62 @@ public final class QueryResponse {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified players to the player list.
|
||||
* @param players the players to add
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder players(Collection<String> players) {
|
||||
this.players.addAll(Preconditions.checkNotNull(players, "players"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified players to the player list.
|
||||
* @param players the players to add
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder players(String... players) {
|
||||
this.players.addAll(Arrays.asList(Preconditions.checkNotNull(players, "players")));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all players from the builder. This does not affect {@link #getCurrentPlayers()}.
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder clearPlayers() {
|
||||
this.players.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy version.
|
||||
* @param proxyVersion the proxy version to set
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder proxyVersion(String proxyVersion) {
|
||||
this.proxyVersion = Preconditions.checkNotNull(proxyVersion, "proxyVersion");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified plugins to the plugins list.
|
||||
* @param plugins the plugins to add
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder plugins(Collection<PluginInformation> plugins) {
|
||||
this.plugins.addAll(Preconditions.checkNotNull(plugins, "plugins"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified plugins to the plugins list.
|
||||
* @param plugins the plugins to add
|
||||
* @return this builder, for chaining
|
||||
*/
|
||||
public Builder plugins(PluginInformation... plugins) {
|
||||
this.plugins.addAll(Arrays.asList(Preconditions.checkNotNull(plugins, "plugins")));
|
||||
this.plugins.addAll(Arrays.asList(plugins));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,14 @@ public final class ServerPing {
|
||||
this(version, players, description, favicon, ModInfo.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a ServerPing instance.
|
||||
* @param version the version of the server
|
||||
* @param players the players on the server
|
||||
* @param description the MOTD for the server
|
||||
* @param favicon the server's favicon
|
||||
* @param modinfo the mods this server runs
|
||||
*/
|
||||
public ServerPing(Version version, @Nullable Players players, Component description,
|
||||
@Nullable Favicon favicon, @Nullable ModInfo modinfo) {
|
||||
this.version = Preconditions.checkNotNull(version, "version");
|
||||
|
@ -11,7 +11,8 @@ import java.util.UUID;
|
||||
public final class GameProfile {
|
||||
|
||||
private final UUID id;
|
||||
private final String undashedId, name;
|
||||
private final String undashedId;
|
||||
private final String name;
|
||||
private final List<Property> properties;
|
||||
|
||||
public GameProfile(UUID id, String name, List<Property> properties) {
|
||||
@ -136,12 +137,21 @@ public final class GameProfile {
|
||||
+ '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Mojang profile property. Just like {@link GameProfile}, this class is immutable.
|
||||
*/
|
||||
public static final class Property {
|
||||
|
||||
private final String name;
|
||||
private final String value;
|
||||
private final String signature;
|
||||
|
||||
/**
|
||||
* Creates a profile property entry.
|
||||
* @param name the name of the property
|
||||
* @param value the value of the property
|
||||
* @param signature the Mojang signature for the property
|
||||
*/
|
||||
public Property(String name, String value, String signature) {
|
||||
this.name = Preconditions.checkNotNull(name, "name");
|
||||
this.value = Preconditions.checkNotNull(value, "value");
|
||||
|
@ -76,10 +76,10 @@ public final class NativeCodeLoader<T> implements Supplier<T> {
|
||||
}
|
||||
|
||||
static final BooleanSupplier MACOS = () ->
|
||||
System.getProperty("os.name", "").equalsIgnoreCase("Mac OS X") &&
|
||||
System.getProperty("os.arch").equals("x86_64");
|
||||
System.getProperty("os.name", "").equalsIgnoreCase("Mac OS X")
|
||||
&& System.getProperty("os.arch").equals("x86_64");
|
||||
static final BooleanSupplier LINUX = () ->
|
||||
System.getProperties().getProperty("os.name", "").equalsIgnoreCase("Linux") &&
|
||||
System.getProperty("os.arch").equals("amd64");
|
||||
System.getProperties().getProperty("os.name", "").equalsIgnoreCase("Linux")
|
||||
&& System.getProperty("os.arch").equals("amd64");
|
||||
static final BooleanSupplier ALWAYS = () -> true;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class Natives {
|
||||
};
|
||||
}
|
||||
|
||||
public static final NativeCodeLoader<VelocityCompressorFactory> compressor = new NativeCodeLoader<>(
|
||||
public static final NativeCodeLoader<VelocityCompressorFactory> compress = new NativeCodeLoader<>(
|
||||
ImmutableList.of(
|
||||
new NativeCodeLoader.Variant<>(NativeCodeLoader.MACOS,
|
||||
copyAndLoadNative("/macosx/velocity-compress.dylib"), "native (macOS)",
|
||||
|
@ -20,13 +20,13 @@ class VelocityCompressorTest {
|
||||
|
||||
@BeforeAll
|
||||
static void checkNatives() {
|
||||
Natives.compressor.getLoadedVariant();
|
||||
Natives.compress.getLoadedVariant();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs({MAC, LINUX})
|
||||
void nativeIntegrityCheck() throws DataFormatException {
|
||||
VelocityCompressor compressor = Natives.compressor.get().create(Deflater.DEFAULT_COMPRESSION);
|
||||
VelocityCompressor compressor = Natives.compress.get().create(Deflater.DEFAULT_COMPRESSION);
|
||||
if (compressor instanceof JavaVelocityCompressor) {
|
||||
compressor.dispose();
|
||||
fail("Loaded regular compressor");
|
||||
|
@ -28,7 +28,7 @@ class VelocityCipherTest {
|
||||
void nativeIntegrityCheck() throws GeneralSecurityException {
|
||||
VelocityCipherFactory factory = Natives.cipher.get();
|
||||
if (factory == JavaVelocityCipher.FACTORY) {
|
||||
fail("Loaded regular compressor");
|
||||
fail("Loaded regular cipher");
|
||||
}
|
||||
check(factory);
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
int level = server.getConfiguration().getCompressionLevel();
|
||||
VelocityCompressor compressor = Natives.compressor.get().create(level);
|
||||
VelocityCompressor compressor = Natives.compress.get().create(level);
|
||||
MinecraftCompressEncoder encoder = new MinecraftCompressEncoder(threshold, compressor);
|
||||
MinecraftCompressDecoder decoder = new MinecraftCompressDecoder(threshold, compressor);
|
||||
|
||||
|
@ -39,7 +39,7 @@ public final class ConnectionManager {
|
||||
|
||||
public void logChannelInformation() {
|
||||
LOGGER.info("Connections will use {} channels, {} compression, {} ciphers", this.transportType,
|
||||
Natives.compressor.getLoadedVariant(), Natives.cipher.getLoadedVariant());
|
||||
Natives.compress.getLoadedVariant(), Natives.cipher.getLoadedVariant());
|
||||
}
|
||||
|
||||
public void bind(final InetSocketAddress address) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren