From e2c06506bc326a2d95b1d95ef9038d391317b5f4 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 22 May 2011 21:43:47 +0000 Subject: [PATCH] Add stuff directly to inventory to prevent theft by standing next to the sign, while someone breaks it. git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1526 e251c2fe-e539-e718-e476-b85c1f46cddb --- .../essentials/EssentialsEcoBlockListener.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java index 10ec0438d..113ad327a 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java @@ -1,5 +1,6 @@ package com.earth2me.essentials; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Material; @@ -74,7 +75,11 @@ public class EssentialsEcoBlockListener extends BlockListener } else if (i1 != null) { - InventoryWorkaround.dropItem(user.getLocation(), i1); + Map leftOver = user.getInventory().addItem(i1); + for (ItemStack itemStack : leftOver.values()) + { + InventoryWorkaround.dropItem(user.getLocation(), itemStack); + } } if (m2) @@ -83,8 +88,13 @@ public class EssentialsEcoBlockListener extends BlockListener } else if (i2 != null) { - InventoryWorkaround.dropItem(user.getLocation(), i2); + Map leftOver = user.getInventory().addItem(i2); + for (ItemStack itemStack : leftOver.values()) + { + InventoryWorkaround.dropItem(user.getLocation(), itemStack); + } } + user.updateInventory(); sign.setType(Material.AIR); }