13
0
geforkt von Mirrors/Velocity

Merge remote-tracking branch 'origin/dev/3.0.0' into dev/3.0.0

Dieser Commit ist enthalten in:
Andrew Steinborn 2021-06-06 03:52:03 -04:00
Commit ef7aeae4ed
10 geänderte Dateien mit 45 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -18,7 +18,7 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
public final class BrigadierCommand implements Command { public final class BrigadierCommand implements Command {
/** /**
* Return code used by a {@link com.mojang.brigadier.Command} to indicate * The return code used by a {@link com.mojang.brigadier.Command} to indicate
* the command execution should be forwarded to the backend server. * the command execution should be forwarded to the backend server.
*/ */
public static final int FORWARD = 0xF6287429; public static final int FORWARD = 0xF6287429;

Datei anzeigen

@ -17,8 +17,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* Represents a command that can be executed by a {@link CommandSource} * Represents a command that can be executed by a {@link CommandSource}
* such as a {@link Player} or the console. * such as a {@link Player} or the console.
* *
* <p>Velocity 1.1.0 introduces specialized command subinterfaces to separate * <p><strong>You must not subclass <code>Command</code></strong>. Use one of the following
* command parsing concerns. These include, in order of preference: * <i>registrable</i> subinterfaces:</p>
* *
* <ul> * <ul>
* <li>{@link BrigadierCommand}, which supports parameterized arguments and * <li>{@link BrigadierCommand}, which supports parameterized arguments and

Datei anzeigen

@ -39,7 +39,9 @@ public interface CommandManager {
* @param alias the first command alias * @param alias the first command alias
* @param command the command to register * @param command the command to register
* @param otherAliases additional aliases * @param otherAliases additional aliases
* @throws IllegalArgumentException if one of the given aliases is already registered * @throws IllegalArgumentException if one of the given aliases is already registered, or
* the given command does not implement a registrable {@link Command} subinterface
* @see Command for a list of registrable {@link Command} subinterfaces
*/ */
default void register(String alias, Command command, String... otherAliases) { default void register(String alias, Command command, String... otherAliases) {
register(metaBuilder(alias).aliases(otherAliases).build(), command); register(metaBuilder(alias).aliases(otherAliases).build(), command);
@ -58,7 +60,9 @@ public interface CommandManager {
* *
* @param meta the command metadata * @param meta the command metadata
* @param command the command to register * @param command the command to register
* @throws IllegalArgumentException if one of the given aliases is already registered * @throws IllegalArgumentException if one of the given aliases is already registered, or
* the given command does not implement a registrable {@link Command} subinterface
* @see Command for a list of registrable {@link Command} subinterfaces
*/ */
void register(CommandMeta meta, Command command); void register(CommandMeta meta, Command command);

Datei anzeigen

@ -24,8 +24,8 @@ public interface CommandMeta {
Collection<String> getAliases(); Collection<String> getAliases();
/** /**
* Returns a collection containing command nodes that provide additional * Returns an immutable collection containing command nodes that provide
* argument metadata and tab-complete suggestions. * additional argument metadata and tab-complete suggestions.
* Note some {@link Command} implementations may not support hinting. * Note some {@link Command} implementations may not support hinting.
* *
* @return the hinting command nodes * @return the hinting command nodes
@ -51,6 +51,8 @@ public interface CommandMeta {
* *
* @param node the command node * @param node the command node
* @return this builder, for chaining * @return this builder, for chaining
* @throws IllegalArgumentException if the node is executable, i.e. has a non-null
* {@link com.mojang.brigadier.Command}, or has a redirect.
*/ */
Builder hint(CommandNode<CommandSource> node); Builder hint(CommandNode<CommandSource> node);

Datei anzeigen

@ -14,6 +14,11 @@ import java.util.concurrent.CompletableFuture;
/** /**
* A command that can be executed with arbitrary arguments. * A command that can be executed with arbitrary arguments.
* *
* <p>Modifying the command tree (e.g. registering a command via
* {@link CommandManager#register(CommandMeta, Command)}) during
* permission checking and suggestions provision results in
* undefined behavior, which may include deadlocks.
*
* @param <I> the type of the command invocation object * @param <I> the type of the command invocation object
*/ */
public interface InvocableCommand<I extends CommandInvocation<?>> extends Command { public interface InvocableCommand<I extends CommandInvocation<?>> extends Command {

Datei anzeigen

@ -106,6 +106,14 @@ public interface ProxyServer extends Audience {
*/ */
Collection<RegisteredServer> matchServer(String partialName); Collection<RegisteredServer> matchServer(String partialName);
/**
* Creates a raw {@link RegisteredServer} without tying it into the internal server map.
*
* @param server the server to register
* @return the {@link RegisteredServer} implementation created by the provided {@link ServerInfo}.
*/
RegisteredServer createRawRegisteredServer(ServerInfo server);
/** /**
* Registers a server with this proxy. A server with this name should not already exist. * Registers a server with this proxy. A server with this name should not already exist.
* *

Datei anzeigen

@ -28,7 +28,6 @@ jar {
attributes 'Implementation-Version': version attributes 'Implementation-Version': version
attributes 'Implementation-Vendor': "Velocity Contributors" attributes 'Implementation-Vendor': "Velocity Contributors"
attributes 'Multi-Release': 'true' attributes 'Multi-Release': 'true'
attributes 'Add-Opens': 'java.base/java.lang'
} }
} }

Datei anzeigen

@ -602,6 +602,11 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
return servers.getAllServers(); return servers.getAllServers();
} }
@Override
public RegisteredServer createRawRegisteredServer(ServerInfo server) {
return servers.createRawRegisteredServer(server);
}
@Override @Override
public RegisteredServer registerServer(ServerInfo server) { public RegisteredServer registerServer(ServerInfo server) {
return servers.register(server); return servers.register(server);

Datei anzeigen

@ -985,7 +985,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
&& !connectedServer.hasCompletedJoin())) { && !connectedServer.hasCompletedJoin())) {
return Optional.of(ConnectionRequestBuilder.Status.CONNECTION_IN_PROGRESS); return Optional.of(ConnectionRequestBuilder.Status.CONNECTION_IN_PROGRESS);
} }
if (connectedServer != null && connectedServer.getServer().equals(server)) { if (connectedServer != null
&& connectedServer.getServer().getServerInfo().equals(server.getServerInfo())) {
return Optional.of(ALREADY_CONNECTED); return Optional.of(ALREADY_CONNECTED);
} }
return Optional.empty(); return Optional.empty();

Datei anzeigen

@ -54,6 +54,17 @@ public class ServerMap {
return ImmutableList.copyOf(servers.values()); return ImmutableList.copyOf(servers.values());
} }
/**
* Creates a raw implementation of a {@link RegisteredServer} without
* tying it to the internal server map.
*
* @param serverInfo the server to create a registered server with
* @return the {@link RegisteredServer} built from the {@link ServerInfo}
*/
public RegisteredServer createRawRegisteredServer(ServerInfo serverInfo) {
return new VelocityRegisteredServer(server, serverInfo);
}
/** /**
* Registers a server with the proxy. * Registers a server with the proxy.
* *
@ -63,7 +74,7 @@ public class ServerMap {
public RegisteredServer register(ServerInfo serverInfo) { public RegisteredServer register(ServerInfo serverInfo) {
Preconditions.checkNotNull(serverInfo, "serverInfo"); Preconditions.checkNotNull(serverInfo, "serverInfo");
String lowerName = serverInfo.getName().toLowerCase(Locale.US); String lowerName = serverInfo.getName().toLowerCase(Locale.US);
VelocityRegisteredServer rs = new VelocityRegisteredServer(server, serverInfo); RegisteredServer rs = createRawRegisteredServer(serverInfo);
RegisteredServer existing = servers.putIfAbsent(lowerName, rs); RegisteredServer existing = servers.putIfAbsent(lowerName, rs);
if (existing != null && !existing.getServerInfo().equals(serverInfo)) { if (existing != null && !existing.getServerInfo().equals(serverInfo)) {