Only enforce CraftPlayer#remove exception on instances of EntityPlayer

Should be more friendly to plugins that dabble in inheriting NMS
entities.
This commit is contained in:
Zach Brown 2019-02-05 07:44:36 -05:00
parent d08d908d6d
commit df424d7a65

View file

@ -12,7 +12,7 @@ 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. 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 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 36a38713..7b7dc7f2 100644 index 36a38713..fbe34290 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@ -22,7 +22,11 @@ index 36a38713..7b7dc7f2 100644
+ +
+ @Override + @Override
+ public void remove() { + public void remove() {
+ throw new UnsupportedOperationException("Calling Entity#remove on players produces undefined (bad) behavior"); + 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 //Paper end