Put the correct sign type into the chest on empty remove (Fixes #313)

This commit is contained in:
Phoenix616 2020-05-20 00:42:28 +01:00
parent e22a50e1cf
commit d868fe8af6

View File

@ -42,12 +42,22 @@ public class EmptyShopDeleter implements Listener {
ShopDestroyedEvent destroyedEvent = new ShopDestroyedEvent(null, event.getSign(), connectedContainer); ShopDestroyedEvent destroyedEvent = new ShopDestroyedEvent(null, event.getSign(), connectedContainer);
ChestShop.callEvent(destroyedEvent); ChestShop.callEvent(destroyedEvent);
Material signType = sign.getType();
sign.getBlock().setType(Material.AIR); sign.getBlock().setType(Material.AIR);
if (Properties.REMOVE_EMPTY_CHESTS && !ChestShopSign.isAdminShop(ownerInventory) && InventoryUtil.isEmpty(ownerInventory)) { if (Properties.REMOVE_EMPTY_CHESTS && !ChestShopSign.isAdminShop(ownerInventory) && InventoryUtil.isEmpty(ownerInventory)) {
connectedContainer.getBlock().setType(Material.AIR); connectedContainer.getBlock().setType(Material.AIR);
} else { } 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!");
}
} }
} }