Close horse inventory on logoff to prevent dupe

This commit is contained in:
Benjamin James Harrison-Sims 2013-07-02 19:00:39 +01:00 committed by md_5
parent 54195222b9
commit 3590fce0d3
2 changed files with 1241 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
From 722e32a4c2502a7dc9638ac3d19efc180a2efed9 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 logoff to prevent dupe
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.3.2