2023-12-06 18:54:52 +01:00
|
|
|
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] Dont block Player#remove if the handle is a custom player
|
|
|
|
|
|
|
|
Upstream throws UOE if you try to call remove on a Player.
|
|
|
|
We just add a check to ensure that the CraftPlayer's handle
|
|
|
|
is a ServerPlayer
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2024-10-24 19:29:35 +02:00
|
|
|
index 5e14d93fe151847969d8c4ca9e1aa960aad39dcc..d4b6a3c2bb63022c00f5d847a1e406ed4efd98c6 100644
|
2023-12-06 18:54:52 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2024-10-24 19:29:35 +02:00
|
|
|
@@ -229,8 +229,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2023-12-06 18:54:52 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void remove() {
|
|
|
|
+ if (this.getHandle().getClass().equals(ServerPlayer.class)) { // special case for NMS plugins inheriting
|
|
|
|
// Will lead to an inconsistent player state if we remove the player as any other entity.
|
|
|
|
throw new UnsupportedOperationException(String.format("Cannot remove player %s, use Player#kickPlayer(String) instead.", this.getName()));
|
|
|
|
+ } else {
|
|
|
|
+ super.remove();
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|