3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2025-01-07 05:40:11 +01:00

Only enforce CraftPlayer#remove exception on instances of EntityPlayer

Should be more friendly to plugins that dabble in inheriting NMS
entities.
Dieser Commit ist enthalten in:
Zach Brown 2019-02-05 07:44:36 -05:00
Ursprung 28cf2696d4
Commit 8211569c9a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: CC9DA35FC5450B76

Datei anzeigen

@ -1,4 +1,4 @@
From 77bf3954e56da679c67b1fab72772d8824ffb401 Mon Sep 17 00:00:00 2001 From 0ccfc3c7b8ddd8ba3b7e3ac5e6d9d107ce7d15ff Mon Sep 17 00:00:00 2001
From: Zach Brown <zach@zachbr.io> From: Zach Brown <zach@zachbr.io>
Date: Mon, 4 Feb 2019 23:33:24 -0500 Date: Mon, 4 Feb 2019 23:33:24 -0500
Subject: [PATCH] Block Entity#remove from being called on Players Subject: [PATCH] Block Entity#remove from being called on Players
@ -12,17 +12,21 @@ 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
@@ -1937,6 +1937,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1937,6 +1937,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void resetCooldown() { public void resetCooldown() {
getHandle().resetCooldown(); getHandle().resetCooldown();
} }
+ +
+ @Override + @Override
+ public void remove() { + 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"); + throw new UnsupportedOperationException("Calling Entity#remove on players produces undefined (bad) behavior");
+ } else {
+ super.remove();
+ }
+ } + }
//Paper end //Paper end