From d74afb013f04562b7d44b89e47051d2dae386cc0 Mon Sep 17 00:00:00 2001 From: CoreyShupe Date: Tue, 1 Jun 2021 02:07:06 -0400 Subject: [PATCH] Initial implementation of raw registered server creation. --- .../com/velocitypowered/api/proxy/ProxyServer.java | 8 ++++++++ .../com/velocitypowered/proxy/VelocityServer.java | 5 +++++ .../com/velocitypowered/proxy/server/ServerMap.java | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java b/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java index 38490200e..11779ce5c 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/ProxyServer.java @@ -107,6 +107,14 @@ public interface ProxyServer extends Audience { */ Collection 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. * diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index fc22b7a22..323f5c7cd 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -673,6 +673,11 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { return servers.getAllServers(); } + @Override + public RegisteredServer createRawRegisteredServer(ServerInfo server) { + return servers.createRawRegisteredServer(server); + } + @Override public RegisteredServer registerServer(ServerInfo server) { return servers.register(server); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/server/ServerMap.java b/proxy/src/main/java/com/velocitypowered/proxy/server/ServerMap.java index 606416490..bffcce605 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/server/ServerMap.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/server/ServerMap.java @@ -53,6 +53,17 @@ public class ServerMap { 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. *