3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

Merge pull request #513 from CoreyShupe/feature/Allow-Raw-Registered-Server-Creation

Initial implementation of raw registered server creation.
Dieser Commit ist enthalten in:
Andrew Steinborn 2021-06-01 13:12:41 +00:00 committet von GitHub
Commit 7fbfdb2f23
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
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);
/**
* 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.
*

Datei anzeigen

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

Datei anzeigen

@ -54,6 +54,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.
*
@ -63,7 +74,7 @@ public class ServerMap {
public RegisteredServer register(ServerInfo serverInfo) {
Preconditions.checkNotNull(serverInfo, "serverInfo");
String lowerName = serverInfo.getName().toLowerCase(Locale.US);
VelocityRegisteredServer rs = new VelocityRegisteredServer(server, serverInfo);
RegisteredServer rs = createRawRegisteredServer(serverInfo);
RegisteredServer existing = servers.putIfAbsent(lowerName, rs);
if (existing != null && !existing.getServerInfo().equals(serverInfo)) {