Paper/CraftBukkit-Patches/0059-Close-Horse-Inventory-on-Disconnect.patch
2013-07-03 08:35:21 +10:00

48 lines
1.9 KiB
Diff

From 90ebcdf6803c60b94bca14371f8056bb01d0721b Mon Sep 17 00:00:00 2001
From: Benjamin James Harrison-Sims <tehrainbowguy@gmail.com>
Date: Tue, 2 Jul 2013 19:00:01 +0100
Subject: [PATCH] Close Horse Inventory on Disconnect
diff --git a/src/main/java/net/minecraft/server/EntityHorse.java b/src/main/java/net/minecraft/server/EntityHorse.java
index 5e7e571..11a7a09 100644
--- a/src/main/java/net/minecraft/server/EntityHorse.java
+++ b/src/main/java/net/minecraft/server/EntityHorse.java
@@ -20,7 +20,7 @@ public class EntityHorse extends EntityAnimal implements IInventoryListener {
public int bp;
public int bq;
protected boolean br;
- private InventoryHorseChest bG;
+ public InventoryHorseChest bG; // Spigot - private -> public
private boolean bH;
protected int bs;
protected float bt;
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index cbe823f..1ca4c81 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -31,6 +31,8 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.util.Vector;
// CraftBukkit end
+import org.bukkit.entity.HumanEntity; //Spigot
+
public abstract class PlayerList {
private static final SimpleDateFormat d = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
@@ -261,6 +263,11 @@ public abstract class PlayerList {
WorldServer worldserver = entityplayer.p();
if (entityplayer.vehicle != null) {
+ if (entityplayer.vehicle instanceof EntityHorse) {
+ for (HumanEntity humanEntity : new ArrayList<HumanEntity>(((EntityHorse) entityplayer.vehicle).bG.getViewers())) {
+ humanEntity.closeInventory();
+ }
+ }
worldserver.removeEntity(entityplayer.vehicle);
System.out.println("removing player mount");
}
--
1.8.1.2