Skip to content

Commit

Permalink
Force kick when safety kicking failed
Browse files Browse the repository at this point in the history
  • Loading branch information
killerprojecte committed Jul 9, 2023
1 parent 5a5a3f7 commit 2c13f7d
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions patches/server/0041-Force-kick-when-safety-kicking-failed.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: killerprojecte <admin@fastmcmirror.org>
Date: Sun, 9 Jul 2023 15:40:26 +0800
Subject: [PATCH] Force kick when safety kicking failed


diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 24583488ee0e15c9017549a13d190e9f3f1b8686..b1bf0fc7bd1e46c672482d9ecd4728a6f389b68c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -7,6 +7,8 @@ import com.google.common.io.BaseEncoding;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair;
import io.netty.buffer.Unpooled;
+import io.papermc.paper.adventure.PaperAdventure;
+import io.papermc.paper.threadedregions.RegionizedServer;
import it.unimi.dsi.fastutil.shorts.ShortArraySet;
import it.unimi.dsi.fastutil.shorts.ShortSet;
import java.io.ByteArrayOutputStream;
@@ -30,6 +32,7 @@ import java.util.WeakHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
import net.minecraft.advancements.AdvancementProgress;
import net.minecraft.core.BlockPos;
@@ -37,6 +40,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.SectionPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
+import net.minecraft.network.Connection;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.PlayerChatMessage;
@@ -605,6 +609,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (connection != null) {
connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause);
}
+ for (Connection connection1 : RegionizedServer.getInstance().getConnections().stream().filter(connection1 ->
+ CraftChatMessage.fromComponent(connection1.getPlayer().getName()).equalsIgnoreCase(getName()) ||
+ connection1.spoofedUUID.equals(getUniqueId()) || connection1.getPlayer().getUUID().equals(getUniqueId()))
+ .collect(Collectors.toList())) {
+ if (connection1.isConnected() || connection1.isPlayerConnected() || connection1.isConnecting()) {
+ connection1.disconnect(message == null ? PaperAdventure.asVanilla(net.kyori.adventure.text.Component.empty()) : PaperAdventure.asVanilla(message));
+ }
+ }
}

@Override

0 comments on commit 2c13f7d

Please sign in to comment.