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

Initial implementation of raw registered server creation.

Dieser Commit ist enthalten in:
CoreyShupe 2021-06-01 02:07:06 -04:00
Ursprung 04db382a18
Commit 150808b4b0
3 geänderte Dateien mit 25 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -105,6 +105,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

@ -600,6 +600,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

@ -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)) {