Paper/Spigot-Server-Patches/0414-Block-Entity-remove-from-being-called-on-Players.patch
Shane Freeder 2828dd1c67 Revert "Don't update snapshot blockstates" (Fixes #1882)
CraftBukkit already checks that we're not trying to copy data
back to the same snapshot, reverting this fixes the ability to
properly update non-snapshot blockstates
2019-03-07 17:21:02 +00:00

37 lines
1.5 KiB
Diff

From 9ca0e55ef61f8e8a91da1955969e98e3f4ca50b7 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
index 36a387137..fbe342902 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1937,6 +1937,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void resetCooldown() {
getHandle().resetCooldown();
}
+
+ @Override
+ public void remove() {
+ 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();
+ }
+ }
//Paper end
// Spigot start
--
2.21.0