From c36ca65e09b8612731c7466b5c5f2b93e946e8ff Mon Sep 17 00:00:00 2001 From: snowleo Date: Thu, 1 Mar 2012 23:09:48 +0100 Subject: [PATCH 1/2] Bukkit broke this sign :( --- .../com/earth2me/essentials/signs/SignDisposal.java | 6 ++++-- .../src/com/earth2me/essentials/signs/SignFree.java | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignDisposal.java b/Essentials/src/com/earth2me/essentials/signs/SignDisposal.java index 77e6164e5..aa6376fa0 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignDisposal.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignDisposal.java @@ -2,7 +2,6 @@ package com.earth2me.essentials.signs; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; -import org.bukkit.event.inventory.InventoryType; public class SignDisposal extends EssentialsSign @@ -15,7 +14,10 @@ public class SignDisposal extends EssentialsSign @Override protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) { - player.getBase().openInventory(ess.getServer().createInventory(player, InventoryType.CHEST)); + player.sendMessage("Bukkit broke this sign :("); + //TODO: wait for a fix in bukkit + //Problem: Items can be duplicated + //player.getBase().openInventory(ess.getServer().createInventory(player, 36)); return true; } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignFree.java b/Essentials/src/com/earth2me/essentials/signs/SignFree.java index a69b4155f..7ab771833 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignFree.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignFree.java @@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; +import com.earth2me.essentials.craftbukkit.InventoryWorkaround; import org.bukkit.Material; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; @@ -33,10 +34,14 @@ public class SignFree extends EssentialsSign throw new SignException(_("cantSpawnItem", "Air")); } - item.setAmount(item.getType().getMaxStackSize() * 9 * 4); - Inventory i = ess.getServer().createInventory(player, InventoryType.CHEST); - i.addItem(item); - player.openInventory(i); + item.setAmount(item.getType().getMaxStackSize()); + InventoryWorkaround.addItem(player.getInventory(), true, item); + player.sendMessage("Item added to your inventory."); + //TODO: wait for a fix in bukkit + //Problem: Items can be duplicated + //Inventory i = ess.getServer().createInventory(player, InventoryType.CHEST); + //i.addItem(item); + //player.openInventory(i); Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), sign.getBlock().getLocation(), ess); return true; } From 6df3b9008a50922987c5100b17b400f9458d4a65 Mon Sep 17 00:00:00 2001 From: snowleo Date: Thu, 1 Mar 2012 23:23:23 +0100 Subject: [PATCH 2/2] update inventory --- Essentials/src/com/earth2me/essentials/signs/SignFree.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Essentials/src/com/earth2me/essentials/signs/SignFree.java b/Essentials/src/com/earth2me/essentials/signs/SignFree.java index 7ab771833..f5f32c38c 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignFree.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignFree.java @@ -37,6 +37,7 @@ public class SignFree extends EssentialsSign item.setAmount(item.getType().getMaxStackSize()); InventoryWorkaround.addItem(player.getInventory(), true, item); player.sendMessage("Item added to your inventory."); + player.updateInventory(); //TODO: wait for a fix in bukkit //Problem: Items can be duplicated //Inventory i = ess.getServer().createInventory(player, InventoryType.CHEST);