2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-02-05 04:43:28 +00:00
|
|
|
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
|
2021-05-09 20:50:09 +00:00
|
|
|
index 3e07e93a272bb65db9f191ae7c3ed18ccc9d3657..5cdefb8978cdd3d29cc120c35040189c4f86f7bf 100644
|
2019-02-05 04:43:28 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2021-05-09 20:50:09 +00:00
|
|
|
@@ -2236,6 +2236,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2019-02-05 04:43:28 +00:00
|
|
|
public void resetCooldown() {
|
2020-08-02 05:39:36 +00:00
|
|
|
getHandle().resetAttackCooldown();
|
2019-02-05 04:43:28 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void remove() {
|
2019-02-05 12:44:36 +00:00
|
|
|
+ if (this.getHandle().getClass().equals(EntityPlayer.class)) { // special case for NMS plugins inheriting
|
|
|
|
+ throw new UnsupportedOperationException("Calling Entity#remove on players produces undefined (bad) behavior");
|
|
|
|
+ } else {
|
|
|
|
+ super.remove();
|
|
|
|
+ }
|
2019-02-05 04:43:28 +00:00
|
|
|
+ }
|
2019-12-12 16:20:43 +00:00
|
|
|
// Paper end
|
2019-02-05 04:43:28 +00:00
|
|
|
|
|
|
|
// Spigot start
|