From d868fe8af6ee80a76654889fafa2e55b615a415f Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Wed, 20 May 2020 00:42:28 +0100 Subject: [PATCH] Put the correct sign type into the chest on empty remove (Fixes #313) --- .../Listeners/PostTransaction/EmptyShopDeleter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/EmptyShopDeleter.java b/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/EmptyShopDeleter.java index e831849..bc4220b 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/EmptyShopDeleter.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/EmptyShopDeleter.java @@ -42,12 +42,22 @@ public class EmptyShopDeleter implements Listener { ShopDestroyedEvent destroyedEvent = new ShopDestroyedEvent(null, event.getSign(), connectedContainer); ChestShop.callEvent(destroyedEvent); + Material signType = sign.getType(); sign.getBlock().setType(Material.AIR); if (Properties.REMOVE_EMPTY_CHESTS && !ChestShopSign.isAdminShop(ownerInventory) && InventoryUtil.isEmpty(ownerInventory)) { connectedContainer.getBlock().setType(Material.AIR); } else { - ownerInventory.addItem(new ItemStack(Material.SIGN, 1)); + if (!signType.isItem()) { + try { + signType = Material.valueOf(signType.name().replace("WALL_", "")); + } catch (IllegalArgumentException ignored) {} + } + if (signType.isItem()) { + ownerInventory.addItem(new ItemStack(signType, 1)); + } else { + ChestShop.getBukkitLogger().warning("Unable to get item for sign " + signType + " to add to removed shop's container!"); + } } }