Improve cookie support during login

This commit is contained in:
md_5 2024-02-10 12:26:26 +11:00
parent eda268b481
commit 464ed0184c
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 9 additions and 1 deletions

View File

@ -40,6 +40,8 @@ import net.md_5.bungee.protocol.Either;
import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.PacketWrapper;
import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.Protocol;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.CookieRequest;
import net.md_5.bungee.protocol.packet.CookieResponse;
import net.md_5.bungee.protocol.packet.EncryptionRequest; import net.md_5.bungee.protocol.packet.EncryptionRequest;
import net.md_5.bungee.protocol.packet.EntityStatus; import net.md_5.bungee.protocol.packet.EntityStatus;
import net.md_5.bungee.protocol.packet.GameState; import net.md_5.bungee.protocol.packet.GameState;
@ -188,6 +190,12 @@ public class ServerConnector extends PacketHandler
ch.setCompressionThreshold( setCompression.getThreshold() ); ch.setCompressionThreshold( setCompression.getThreshold() );
} }
@Override
public void handle(CookieRequest cookieRequest) throws Exception
{
user.retrieveCookie( cookieRequest.getCookie() ).thenAccept( (cookie) -> ch.write( new CookieResponse( cookieRequest.getCookie(), cookie ) ) );
}
@Override @Override
public void handle(Login login) throws Exception public void handle(Login login) throws Exception
{ {

View File

@ -129,7 +129,7 @@ public class UpstreamBridge extends PacketHandler
@Override @Override
public boolean shouldHandle(PacketWrapper packet) throws Exception public boolean shouldHandle(PacketWrapper packet) throws Exception
{ {
return con.getServer() != null || packet.packet instanceof PluginMessage; return con.getServer() != null || packet.packet instanceof PluginMessage || packet.packet instanceof CookieResponse;
} }
@Override @Override