mirror of
https://github.com/PaperMC/Velocity.git
synced 2024-11-27 06:30:35 +08:00
Add a new loginstatus for CANCELLED_BY_USER_BEFORE_COMPLETE
This commit is contained in:
parent
4c1db86760
commit
079b352c97
@ -58,6 +58,7 @@ public final class DisconnectEvent {
|
|||||||
SUCCESSFUL_LOGIN,
|
SUCCESSFUL_LOGIN,
|
||||||
CONFLICTING_LOGIN,
|
CONFLICTING_LOGIN,
|
||||||
CANCELLED_BY_USER,
|
CANCELLED_BY_USER,
|
||||||
CANCELLED_BY_PROXY
|
CANCELLED_BY_PROXY,
|
||||||
|
CANCELLED_BY_USER_BEFORE_COMPLETE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import static com.velocitypowered.proxy.util.EncryptionUtils.decryptRsa;
|
|||||||
import static com.velocitypowered.proxy.util.EncryptionUtils.generateServerId;
|
import static com.velocitypowered.proxy.util.EncryptionUtils.generateServerId;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||||
|
import com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus;
|
||||||
import com.velocitypowered.api.event.connection.LoginEvent;
|
import com.velocitypowered.api.event.connection.LoginEvent;
|
||||||
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
||||||
import com.velocitypowered.api.event.connection.PreLoginEvent;
|
import com.velocitypowered.api.event.connection.PreLoginEvent;
|
||||||
@ -224,13 +226,13 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
if (!mcConnection.isClosed()) {
|
if (!mcConnection.isClosed()) {
|
||||||
// wait for permissions to load, then set the players permission function
|
// wait for permissions to load, then set the players permission function
|
||||||
player.setPermissionFunction(event.createFunction(player));
|
player.setPermissionFunction(event.createFunction(player));
|
||||||
finishLogin(player);
|
completeLoginProtocolPhaseAndInitialize(player);
|
||||||
}
|
}
|
||||||
}, mcConnection.eventLoop());
|
}, mcConnection.eventLoop());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishLogin(ConnectedPlayer player) {
|
private void completeLoginProtocolPhaseAndInitialize(ConnectedPlayer player) {
|
||||||
int threshold = server.getConfiguration().getCompressionThreshold();
|
int threshold = server.getConfiguration().getCompressionThreshold();
|
||||||
if (threshold >= 0 && mcConnection.getProtocolVersion().compareTo(MINECRAFT_1_8) >= 0) {
|
if (threshold >= 0 && mcConnection.getProtocolVersion().compareTo(MINECRAFT_1_8) >= 0) {
|
||||||
mcConnection.write(new SetCompression(threshold));
|
mcConnection.write(new SetCompression(threshold));
|
||||||
@ -253,6 +255,8 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
.thenAcceptAsync(event -> {
|
.thenAcceptAsync(event -> {
|
||||||
if (mcConnection.isClosed()) {
|
if (mcConnection.isClosed()) {
|
||||||
// The player was disconnected
|
// The player was disconnected
|
||||||
|
server.getEventManager().fireAndForget(new DisconnectEvent(player,
|
||||||
|
LoginStatus.CANCELLED_BY_USER_BEFORE_COMPLETE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user