-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if player is online in CraftPlayer#closeInventory(InventoryClos…
…eEvent.Reason)
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
patches/server/1073-Check-if-player-is-online-in-CraftPlayer-closeInvent.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: bridge <[email protected]> | ||
Date: Sun, 1 Dec 2024 15:43:12 +0100 | ||
Subject: [PATCH] Check if player is online in | ||
CraftPlayer#closeInventory(InventoryCloseEvent.Reason) | ||
|
||
|
||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | ||
index 554714e449d1d2439b05d7e15f72afccd17d4df5..8bd2ab531e7488faea5fb8935696ed8559762099 100644 | ||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | ||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | ||
@@ -175,6 +175,7 @@ import org.bukkit.entity.EnderPearl; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.entity.Player; | ||
+import org.bukkit.event.inventory.InventoryCloseEvent; | ||
import org.bukkit.event.player.PlayerExpCooldownChangeEvent; | ||
import org.bukkit.event.player.PlayerHideEntityEvent; | ||
import org.bukkit.event.player.PlayerRegisterChannelEvent; | ||
@@ -3580,4 +3581,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { | ||
this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundEntityEventPacket(((CraftEntity) target).getHandle(), effect.getData())); | ||
} | ||
// Paper end - entity effect API | ||
+ | ||
+ // Paper start - close inventory sanity check | ||
+ @Override | ||
+ public void closeInventory(final InventoryCloseEvent.Reason reason) { | ||
+ if (!this.isOnline()) { | ||
+ throw new IllegalStateException("Cannot close inventory for offline player"); | ||
+ } | ||
+ | ||
+ super.closeInventory(reason); | ||
+ } | ||
+ // Paper end | ||
} |