2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Zach Brown <zach@zachbr.io>
|
|
|
|
Date: Mon, 4 Feb 2019 23:33:24 -0500
|
|
|
|
Subject: [PATCH] Block Entity#remove from being called on Players
|
|
|
|
|
|
|
|
This doesn't result in the same behavior as other entities and causes
|
|
|
|
several problems. Anyone ever complain about the "Cannot send chat
|
|
|
|
message" thing? That's one of the issues this causes, among others.
|
|
|
|
|
|
|
|
If a plugin developer can come up with a valid reason to call this on a
|
|
|
|
Player we will look at limiting the scope of this change. It appears to
|
|
|
|
be unintentional in the few cases we've seen so far.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2023-08-06 02:21:59 +02:00
|
|
|
index 22b8b61f260f91d7c79b3772af3134a81db304ac..4714d063f18806187fbd39315467ce467e30c6a2 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2023-08-06 02:21:59 +02:00
|
|
|
@@ -2864,6 +2864,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-06-11 14:02:28 +02:00
|
|
|
public void resetCooldown() {
|
|
|
|
getHandle().resetAttackStrengthTicker();
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void remove() {
|
|
|
|
+ if (this.getHandle().getClass().equals(ServerPlayer.class)) { // special case for NMS plugins inheriting
|
|
|
|
+ throw new UnsupportedOperationException("Calling Entity#remove on players produces undefined (bad) behavior");
|
|
|
|
+ } else {
|
|
|
|
+ super.remove();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
// Spigot start
|
2021-11-24 01:44:41 +01:00
|
|
|
private final Player.Spigot spigot = new Player.Spigot()
|