mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
44 lines
2 KiB
Diff
44 lines
2 KiB
Diff
From 7b7210290f1837231a1bce3da41a4f07659c94ff Mon Sep 17 00:00:00 2001
|
|
From: md_5 <md_5@live.com.au>
|
|
Date: Thu, 27 Jun 2013 17:26:09 +1000
|
|
Subject: [PATCH] Properly Close Inventories
|
|
|
|
Properly close inventories when unloading and switching worlds.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index 95373e0a4..86bcc60e3 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -945,6 +945,15 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
}
|
|
|
|
public void unloadChunk(Chunk chunk) {
|
|
+ // Spigot Start
|
|
+ for (TileEntity tileentity : chunk.getTileEntities().values()) {
|
|
+ if (tileentity instanceof IInventory) {
|
|
+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((IInventory) tileentity).getViewers())) {
|
|
+ h.closeInventory();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Spigot End
|
|
this.tileEntityListUnload.addAll(chunk.getTileEntities().values());
|
|
EntitySlice[] aentityslice = chunk.getEntitySlices();
|
|
int i = aentityslice.length;
|
|
@@ -971,6 +980,13 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
|
|
public void unregisterEntity(Entity entity) {
|
|
org.spigotmc.AsyncCatcher.catchOp("entity unregister"); // Spigot
|
|
+ // Spigot Start
|
|
+ if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder) {
|
|
+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) {
|
|
+ h.closeInventory();
|
|
+ }
|
|
+ }
|
|
+ // Spigot End
|
|
if (entity instanceof EntityEnderDragon) {
|
|
EntityComplexPart[] aentitycomplexpart = ((EntityEnderDragon) entity).eK();
|
|
int i = aentitycomplexpart.length;
|
|
--
|
|
2.25.1
|
|
|