From 354b48b6bfca8282c621c2830153d34a0bbe9cb0 Mon Sep 17 00:00:00 2001 From: altrisi Date: Wed, 26 Jul 2023 19:15:43 +0200 Subject: [PATCH 1/2] Allow fake players to be `/kick`ed --- .../java/carpet/patches/NetHandlerPlayServerFake.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/carpet/patches/NetHandlerPlayServerFake.java b/src/main/java/carpet/patches/NetHandlerPlayServerFake.java index a8e5b852e7..7cafcbd61a 100644 --- a/src/main/java/carpet/patches/NetHandlerPlayServerFake.java +++ b/src/main/java/carpet/patches/NetHandlerPlayServerFake.java @@ -2,7 +2,6 @@ import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.network.protocol.Packet; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerGamePacketListenerImpl; @@ -24,10 +23,7 @@ public void send(final Packet packetIn) @Override public void disconnect(Component message) { - if (message.getContents() instanceof TranslatableContents text && (text.getKey().equals("multiplayer.disconnect.idling") || text.getKey().equals("multiplayer.disconnect.duplicate_login"))) - { - ((EntityPlayerMPFake) player).kill(message); - } + ((EntityPlayerMPFake) player).kill(message); } @Override @@ -41,6 +37,3 @@ public void teleport(double d, double e, double f, float g, float h, Set Date: Wed, 26 Jul 2023 19:29:59 +0200 Subject: [PATCH 2/2] Handle whitelist disconnect triggers --- src/main/java/carpet/patches/NetHandlerPlayServerFake.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/carpet/patches/NetHandlerPlayServerFake.java b/src/main/java/carpet/patches/NetHandlerPlayServerFake.java index 7cafcbd61a..98fa0eef61 100644 --- a/src/main/java/carpet/patches/NetHandlerPlayServerFake.java +++ b/src/main/java/carpet/patches/NetHandlerPlayServerFake.java @@ -2,6 +2,7 @@ import net.minecraft.network.Connection; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.network.protocol.Packet; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerGamePacketListenerImpl; @@ -23,6 +24,12 @@ public void send(final Packet packetIn) @Override public void disconnect(Component message) { + if (message.getContents() instanceof TranslatableContents text && text.getKey().equals("multiplayer.disconnect.not_whitelisted")) + { + // Whitelist stuff triggers this in multiple places and we shouldn't let fake players randomly disconnect + // as we don't expect them to be whitelisted + return; + } ((EntityPlayerMPFake) player).kill(message); }