Paper/Spigot-Server-Patches/0356-Block-Entity-remove-from-being-called-on-Players.patch
Zach Brown ef170ee659
Update upstream B/CB/S
--- work/Bukkit
Submodule work/Bukkit 6eac6d70..1ef8b9d9:
  > Add Player#openBook(ItemStack) method

--- work/CraftBukkit
Submodule work/CraftBukkit 17543ecf..649921e5:
  > Add Player#openBook(ItemStack) method
  > SPIGOT-2000: Picking up items to shield slot working inconsistently when inventory is full
  > SPIGOT-5037: Player.openMerchant does not show merchant level
  > SPIGOT-5038: Inventory.getHolder returns null for wandering traders

--- work/Spigot
Submodule work/Spigot baafee91..df0eb250:
  > SPIGOT-5043: Desync if world is changed in PlayerSpawnLocationEvent
  > Rebuild patches

Implementation developer note:
This patch adds a "pre-source" patch system for fixing malformed patches
from upstream directly. This seems to keep happening so it's best we
have some way to deal with them. This system brings those issues into
our domain rather than needing to wait for upstream to fix their
malformed files.
2019-06-08 15:33:05 -05:00

37 lines
1.5 KiB
Diff

From 22ce97740d4b78e72dddb71113be1b096ac02222 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 b701e4368..484b21f45 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1965,6 +1965,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