Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistency with player logins vs player disconnects #3541

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
18 changes: 16 additions & 2 deletions proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
Expand Up @@ -39,6 +39,7 @@
import net.md_5.bungee.api.event.PreLoginEvent;
import net.md_5.bungee.api.event.ProxyPingEvent;
import net.md_5.bungee.api.event.ServerConnectEvent;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.chat.ComponentSerializer;
import net.md_5.bungee.http.HttpClient;
import net.md_5.bungee.jni.cipher.BungeeCipher;
Expand Down Expand Up @@ -136,6 +137,15 @@ public void connected(ChannelWrapper channel) throws Exception
this.ch = channel;
}

@Override
public void disconnected(ChannelWrapper channel) throws Exception {
if ( this.thisState == State.FINISHING )
{
PlayerDisconnectEvent event = new PlayerDisconnectEvent( getUserConnection() );
bungee.getPluginManager().callEvent( event );
}
}

@Override
public void exception(Throwable t) throws Exception
{
Expand Down Expand Up @@ -594,7 +604,7 @@ public void run()
{
if ( !ch.isClosing() )
{
userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
userCon = getUserConnection();
userCon.setCompressionThreshold( BungeeCord.getInstance().config.getCompressionThreshold() );

if ( getVersion() < ProtocolConstants.MINECRAFT_1_20_2 )
Expand Down Expand Up @@ -776,4 +786,8 @@ public void relayMessage(PluginMessage input) throws Exception
brandMessage = input;
}
}
}

private UserConnection getUserConnection() {
return userCon == null ? new UserConnection( bungee, ch, getName(), InitialHandler.this ) : userCon;
f4n74z14 marked this conversation as resolved.
Show resolved Hide resolved
}
}