Forge server switching
This commit is contained in:
parent
8a00f85993
commit
ae6e0e8c4c
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user