From dd57b4aec5280edcd156b1498c504fb1761ff238 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 27 Nov 2023 19:10:53 +1100 Subject: [PATCH] #1305: Don't allow Player removal via Entity#remove By: DerFrZocker --- .../java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index baf840c372..325285aaf6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -206,6 +206,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return getHandle().getGameProfile(); } + @Override + public void remove() { + // Will lead to an inconsistent player state if we remove the player as any other entity. + throw new UnsupportedOperationException(String.format("Cannot remove player %s, use Player#kickPlayer(String) instead.", getName())); + } + @Override public boolean isOp() { return server.getHandle().isOp(getProfile());