Forge server switching

This commit is contained in:
Adrian Bergqvist 2022-06-27 20:26:54 +02:00
parent 8a00f85993
commit ae6e0e8c4c
No known key found for this signature in database
GPG Key ID: FAE7D8EDE225E686
3 changed files with 22 additions and 2 deletions

View File

@ -31,6 +31,7 @@ public class Ambassador {
private ForgeHandshakeHandler forgeHandshakeHandler;
@Inject
public Ambassador(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
this.server = server;
@ -74,6 +75,12 @@ public class Ambassador {
continuation.resume();
}
}
if (forgeServerConnectionOptional.isEmpty()) {
forgeServerConnection.setDefaultClientModlist(forgeConnection.get().getRecivedClientModlist());
forgeServerConnection.setDefaultClientACK(ForgeConnection.getRecivedClientACK());
forgeHandshakeHandler.registerForgeServer(event.getOriginalServer(), forgeServerConnection);
}
});
} else {
continuation.resume();

View File

@ -11,6 +11,7 @@ public class ForgeConnection {
private final LoginPhaseConnection connection;
private byte[] recivedClientModlist;
private static byte[] recivedClientACK;
private ForgeHandshakeUtils.CachedServerHandshake transmittedHandshake;
@ -65,7 +66,10 @@ public class ForgeConnection {
CompletableFuture<byte[]> future = new CompletableFuture<byte[]>();
for (int i = 0;i<otherPackets.size();i++) {
connection.sendLoginPluginMessage(MinecraftChannelIdentifier.create("fml","loginwrapper"), otherPackets.get(i),
(i<(otherPackets.size()-1)) ? responseBody -> {} : future::complete);
(i<(otherPackets.size()-1)) ? responseBody -> {} : responseBody -> {
recivedClientACK = responseBody;
future.complete(responseBody);
});
}
return future;
}
@ -78,4 +82,11 @@ public class ForgeConnection {
return transmittedHandshake;
}
public byte[] getRecivedClientModlist() {
return recivedClientModlist;
}
public static byte[] getRecivedClientACK() {
return recivedClientACK;
}
}

View File

@ -79,7 +79,9 @@ public class ForgeHandshakeHandler {
return Optional.ofNullable(forgeServerConnectionMap.get(registeredServer));
}
public void registerForgeServer(RegisteredServer server, ForgeServerConnection forgeServerConnection) {
forgeServerConnectionMap.put(server,forgeServerConnection);
}
@Subscribe
public void onServerLoginPluginMessageEvent(ServerLoginPluginMessageEvent event, Continuation continuation) {