geforkt von Mirrors/Paper
SPIGOT-7876: Can't kick player or disconnect player in PlayerLoginEvent when checking for cookies
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
84f1d558c3
Commit
0916d51f5d
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/server/network/LoginListener.java
|
--- a/net/minecraft/server/network/LoginListener.java
|
||||||
+++ b/net/minecraft/server/network/LoginListener.java
|
+++ b/net/minecraft/server/network/LoginListener.java
|
||||||
@@ -44,8 +44,33 @@
|
@@ -44,8 +44,38 @@
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@ -26,16 +26,21 @@
|
|||||||
+ public EnumProtocol getProtocol() {
|
+ public EnumProtocol getProtocol() {
|
||||||
+ return EnumProtocol.LOGIN;
|
+ return EnumProtocol.LOGIN;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void sendPacket(Packet<?> packet) {
|
+ public void sendPacket(Packet<?> packet) {
|
||||||
+ this.connection.send(packet);
|
+ this.connection.send(packet);
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
|
+ @Override
|
||||||
|
+ public void kickPlayer(IChatBaseComponent reason) {
|
||||||
|
+ disconnect(reason);
|
||||||
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
|
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
|
||||||
static final Logger LOGGER = LogUtils.getLogger();
|
static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
||||||
@@ -60,6 +85,7 @@
|
@@ -60,6 +90,7 @@
|
||||||
private GameProfile authenticatedProfile;
|
private GameProfile authenticatedProfile;
|
||||||
private final String serverId;
|
private final String serverId;
|
||||||
private final boolean transferred;
|
private final boolean transferred;
|
||||||
@ -43,7 +48,7 @@
|
|||||||
|
|
||||||
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager, boolean flag) {
|
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager, boolean flag) {
|
||||||
this.state = LoginListener.EnumProtocolState.HELLO;
|
this.state = LoginListener.EnumProtocolState.HELLO;
|
||||||
@@ -76,6 +102,12 @@
|
@@ -76,6 +107,12 @@
|
||||||
this.verifyLoginAndFinishConnectionSetup((GameProfile) Objects.requireNonNull(this.authenticatedProfile));
|
this.verifyLoginAndFinishConnectionSetup((GameProfile) Objects.requireNonNull(this.authenticatedProfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +61,7 @@
|
|||||||
if (this.state == LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT && !this.isPlayerAlreadyInWorld((GameProfile) Objects.requireNonNull(this.authenticatedProfile))) {
|
if (this.state == LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT && !this.isPlayerAlreadyInWorld((GameProfile) Objects.requireNonNull(this.authenticatedProfile))) {
|
||||||
this.finishLoginAndWaitForClient(this.authenticatedProfile);
|
this.finishLoginAndWaitForClient(this.authenticatedProfile);
|
||||||
}
|
}
|
||||||
@@ -86,6 +118,13 @@
|
@@ -86,6 +123,13 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +75,7 @@
|
|||||||
@Override
|
@Override
|
||||||
public boolean isAcceptingMessages() {
|
public boolean isAcceptingMessages() {
|
||||||
return this.connection.isConnected();
|
return this.connection.isConnected();
|
||||||
@@ -131,7 +170,27 @@
|
@@ -131,7 +175,27 @@
|
||||||
this.state = LoginListener.EnumProtocolState.KEY;
|
this.state = LoginListener.EnumProtocolState.KEY;
|
||||||
this.connection.send(new PacketLoginOutEncryptionBegin("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true));
|
this.connection.send(new PacketLoginOutEncryptionBegin("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge, true));
|
||||||
} else {
|
} else {
|
||||||
@ -99,7 +104,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -144,10 +203,24 @@
|
@@ -144,10 +208,24 @@
|
||||||
|
|
||||||
private void verifyLoginAndFinishConnectionSetup(GameProfile gameprofile) {
|
private void verifyLoginAndFinishConnectionSetup(GameProfile gameprofile) {
|
||||||
PlayerList playerlist = this.server.getPlayerList();
|
PlayerList playerlist = this.server.getPlayerList();
|
||||||
@ -127,7 +132,7 @@
|
|||||||
} else {
|
} else {
|
||||||
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
|
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
|
||||||
this.connection.send(new PacketLoginOutSetCompression(this.server.getCompressionThreshold()), PacketSendListener.thenRun(() -> {
|
this.connection.send(new PacketLoginOutSetCompression(this.server.getCompressionThreshold()), PacketSendListener.thenRun(() -> {
|
||||||
@@ -155,7 +228,7 @@
|
@@ -155,7 +233,7 @@
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +141,7 @@
|
|||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.state = LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT;
|
this.state = LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT;
|
||||||
@@ -205,6 +278,12 @@
|
@@ -205,6 +283,12 @@
|
||||||
if (profileresult != null) {
|
if (profileresult != null) {
|
||||||
GameProfile gameprofile = profileresult.profile();
|
GameProfile gameprofile = profileresult.profile();
|
||||||
|
|
||||||
@ -149,7 +154,7 @@
|
|||||||
LoginListener.LOGGER.info("UUID of player {} is {}", gameprofile.getName(), gameprofile.getId());
|
LoginListener.LOGGER.info("UUID of player {} is {}", gameprofile.getName(), gameprofile.getId());
|
||||||
LoginListener.this.startClientVerification(gameprofile);
|
LoginListener.this.startClientVerification(gameprofile);
|
||||||
} else if (LoginListener.this.server.isSingleplayer()) {
|
} else if (LoginListener.this.server.isSingleplayer()) {
|
||||||
@@ -222,6 +301,11 @@
|
@@ -222,6 +306,11 @@
|
||||||
LoginListener.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.authservers_down"));
|
LoginListener.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.authservers_down"));
|
||||||
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
|
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
|
||||||
}
|
}
|
||||||
@ -161,7 +166,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -238,6 +322,43 @@
|
@@ -238,6 +327,43 @@
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +210,7 @@
|
|||||||
@Override
|
@Override
|
||||||
public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket serverboundcustomqueryanswerpacket) {
|
public void handleCustomQueryPacket(ServerboundCustomQueryAnswerPacket serverboundcustomqueryanswerpacket) {
|
||||||
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||||
@@ -245,10 +366,11 @@
|
@@ -245,10 +371,11 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket serverboundloginacknowledgedpacket) {
|
public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket serverboundloginacknowledgedpacket) {
|
||||||
@ -218,7 +223,7 @@
|
|||||||
|
|
||||||
this.connection.setupInboundProtocol(ConfigurationProtocols.SERVERBOUND, serverconfigurationpacketlistenerimpl);
|
this.connection.setupInboundProtocol(ConfigurationProtocols.SERVERBOUND, serverconfigurationpacketlistenerimpl);
|
||||||
serverconfigurationpacketlistenerimpl.startConfiguration();
|
serverconfigurationpacketlistenerimpl.startConfiguration();
|
||||||
@@ -264,12 +386,18 @@
|
@@ -264,12 +391,18 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCookieResponse(ServerboundCookieResponsePacket serverboundcookieresponsepacket) {
|
public void handleCookieResponse(ServerboundCookieResponsePacket serverboundcookieresponsepacket) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||||
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||||
@@ -28,8 +28,39 @@
|
@@ -28,8 +28,44 @@
|
||||||
import net.minecraft.util.thread.IAsyncTaskHandler;
|
import net.minecraft.util.thread.IAsyncTaskHandler;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@ -20,14 +20,14 @@
|
|||||||
+import org.bukkit.craftbukkit.util.Waitable;
|
+import org.bukkit.craftbukkit.util.Waitable;
|
||||||
+import org.bukkit.event.player.PlayerKickEvent;
|
+import org.bukkit.event.player.PlayerKickEvent;
|
||||||
+import org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
+import org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
||||||
|
+
|
||||||
+public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener, CraftPlayer.TransferCookieConnection {
|
+public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener, CraftPlayer.TransferCookieConnection {
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public boolean isTransferred() {
|
+ public boolean isTransferred() {
|
||||||
+ return this.transferred;
|
+ return this.transferred;
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public EnumProtocol getProtocol() {
|
+ public EnumProtocol getProtocol() {
|
||||||
+ return protocol();
|
+ return protocol();
|
||||||
@ -37,11 +37,16 @@
|
|||||||
+ public void sendPacket(Packet<?> packet) {
|
+ public void sendPacket(Packet<?> packet) {
|
||||||
+ send(packet);
|
+ send(packet);
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void kickPlayer(IChatBaseComponent reason) {
|
||||||
|
+ disconnect(reason);
|
||||||
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
public static final int LATENCY_CHECK_INTERVAL = 15000;
|
public static final int LATENCY_CHECK_INTERVAL = 15000;
|
||||||
private static final int CLOSED_LISTENER_TIMEOUT = 15000;
|
private static final int CLOSED_LISTENER_TIMEOUT = 15000;
|
||||||
@@ -46,12 +77,24 @@
|
@@ -46,12 +82,24 @@
|
||||||
private int latency;
|
private int latency;
|
||||||
private volatile boolean suspendFlushingOnServerThread = false;
|
private volatile boolean suspendFlushingOnServerThread = false;
|
||||||
|
|
||||||
@ -67,7 +72,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void close() {
|
private void close() {
|
||||||
@@ -73,6 +116,7 @@
|
@@ -73,6 +121,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleKeepAlive(ServerboundKeepAlivePacket serverboundkeepalivepacket) {
|
public void handleKeepAlive(ServerboundKeepAlivePacket serverboundkeepalivepacket) {
|
||||||
@ -75,7 +80,7 @@
|
|||||||
if (this.keepAlivePending && serverboundkeepalivepacket.getId() == this.keepAliveChallenge) {
|
if (this.keepAlivePending && serverboundkeepalivepacket.getId() == this.keepAliveChallenge) {
|
||||||
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
||||||
|
|
||||||
@@ -87,8 +131,56 @@
|
@@ -87,8 +136,56 @@
|
||||||
@Override
|
@Override
|
||||||
public void handlePong(ServerboundPongPacket serverboundpongpacket) {}
|
public void handlePong(ServerboundPongPacket serverboundpongpacket) {}
|
||||||
|
|
||||||
@ -133,7 +138,7 @@
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleResourcePackResponse(ServerboundResourcePackPacket serverboundresourcepackpacket) {
|
public void handleResourcePackResponse(ServerboundResourcePackPacket serverboundresourcepackpacket) {
|
||||||
@@ -97,11 +189,18 @@
|
@@ -97,11 +194,18 @@
|
||||||
ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), serverboundresourcepackpacket.id());
|
ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), serverboundresourcepackpacket.id());
|
||||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
||||||
}
|
}
|
||||||
@ -152,7 +157,7 @@
|
|||||||
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +208,7 @@
|
@@ -109,7 +213,7 @@
|
||||||
this.server.getProfiler().push("keepAlive");
|
this.server.getProfiler().push("keepAlive");
|
||||||
long i = SystemUtils.getMillis();
|
long i = SystemUtils.getMillis();
|
||||||
|
|
||||||
@ -161,7 +166,7 @@
|
|||||||
if (this.keepAlivePending) {
|
if (this.keepAlivePending) {
|
||||||
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
|
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
|
||||||
} else if (this.checkIfClosed(i)) {
|
} else if (this.checkIfClosed(i)) {
|
||||||
@@ -149,6 +248,14 @@
|
@@ -149,6 +253,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
|
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
|
||||||
@ -176,7 +181,7 @@
|
|||||||
if (packet.isTerminal()) {
|
if (packet.isTerminal()) {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
@@ -173,15 +280,61 @@
|
@@ -173,15 +285,61 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(DisconnectionDetails disconnectiondetails) {
|
public void disconnect(DisconnectionDetails disconnectiondetails) {
|
||||||
|
@ -274,6 +274,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
EnumProtocol getProtocol();
|
EnumProtocol getProtocol();
|
||||||
|
|
||||||
void sendPacket(Packet<?> packet);
|
void sendPacket(Packet<?> packet);
|
||||||
|
|
||||||
|
void kickPlayer(IChatBaseComponent reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record CookieFuture(MinecraftKey key, CompletableFuture<byte[]> future) {
|
public record CookieFuture(MinecraftKey key, CompletableFuture<byte[]> future) {
|
||||||
@ -477,9 +479,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kickPlayer(String message) {
|
public void kickPlayer(String message) {
|
||||||
if (getHandle().connection == null) return;
|
getHandle().transferCookieConnection.kickPlayer(CraftChatMessage.fromStringOrEmpty(message, true));
|
||||||
|
|
||||||
getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren