3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 19:10:09 +01:00
Paper/CraftBukkit-Patches/0030-Properly-Close-Inventories.patch

53 Zeilen
2.3 KiB
Diff

2016-03-01 01:23:45 +01:00
From 2dd0071691dbc596290019977fa9665463e7870b 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/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
2016-02-29 22:33:06 +01:00
index 20b945c..f68abb4 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
2016-02-29 22:33:06 +01:00
@@ -761,6 +761,18 @@ public class Chunk {
while (iterator.hasNext()) {
TileEntity tileentity = (TileEntity) iterator.next();
+ // Spigot Start
+ if ( tileentity instanceof IInventory )
+ {
2014-11-28 02:17:45 +01:00
+ for ( org.bukkit.entity.HumanEntity h : Lists.<org.bukkit.entity.HumanEntity>newArrayList((List<org.bukkit.entity.HumanEntity>) ( (IInventory) tileentity ).getViewers() ) )
+ {
+ if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity )
+ {
+ ( (org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeInventory();
+ }
+ }
+ }
+ // Spigot End
2014-11-28 02:17:45 +01:00
this.world.b(tileentity);
}
2016-02-29 22:33:06 +01:00
@@ -771,6 +783,18 @@ public class Chunk {
2014-11-28 02:17:45 +01:00
java.util.Iterator<Entity> iter = newList.iterator();
while (iter.hasNext()) {
2014-11-28 02:17:45 +01:00
Entity entity = iter.next();
+ // Spigot Start
+ if ( entity instanceof IInventory )
+ {
2014-11-28 02:17:45 +01:00
+ for ( org.bukkit.entity.HumanEntity h : Lists.<org.bukkit.entity.HumanEntity>newArrayList( (List<org.bukkit.entity.HumanEntity>) ( (IInventory) entity ).getViewers() ) )
+ {
+ if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity )
+ {
+ ( (org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeInventory();
+ }
+ }
+ }
+ // Spigot End
// Do not pass along players, as doing so can get them stuck outside of time.
// (which for example disables inventory icon updates and prevents block breaking)
--
2016-02-29 22:33:06 +01:00
2.5.0