Paper/Spigot-Server-Patches/0330-Block-Entity-remove-from-being-called-on-Players.patch
Aikar 0823d3fdce
[Auto] Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
1cb03826 SPIGOT-5900: Re-order Material enum entries to match Minecraft's order
fdd705db #507: Add hasDiscoveredRecipe() and getDiscoveredRecipes()

CraftBukkit Changes:
551e770f5 SPIGOT-5900: Add test for the order of Material enum entries
8297676c2 #682: Add hasDiscoveredRecipe() and getDiscoveredRecipes()
2020-07-01 19:41:58 -04:00

34 lines
1.5 KiB
Diff

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
index 8a251bb55c79c34880599a490efd271a36a09a04..3f6db7e3fcc8fc5e8e1aa1f9add4bfe12f824d0b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2010,6 +2010,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