1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-22 01:58:54 +00:00

#1 bugfix - /qs clean throws a ClassCastException after a shop chest was

forcefully removed from the world
This commit is contained in:
KaiKikuchi 2015-07-26 00:44:31 +02:00
parent 5e78c5efb7
commit 1e5eccc25b
2 changed files with 19 additions and 9 deletions

View File

@ -396,6 +396,8 @@ public class QS implements CommandExecutor {
int i = 0;
while (shIt.hasNext()) {
Shop shop = shIt.next();
try {
if (shop.getLocation().getWorld() != null && shop.isSelling() && shop.getRemainingStock() == 0 && shop instanceof ContainerShop) {
ContainerShop cs = (ContainerShop) shop;
if (cs.isDoubleShop())
@ -403,6 +405,9 @@ public class QS implements CommandExecutor {
shIt.remove(); // Is selling, but has no stock, and is a chest shop, but is not a double shop. Can be deleted safely.
i++;
}
} catch (IllegalStateException e) {
shIt.remove(); // The shop is not there anymore, remove it
}
}
MsgUtil.clean();
sender.sendMessage(MsgUtil.getMessage("command.cleaned", "" + i));

View File

@ -216,9 +216,14 @@ public class ContainerShop implements Shop {
/**
* @return The chest this shop is based on.
*/
public Inventory getInventory() {
InventoryHolder container = (InventoryHolder) this.loc.getBlock().getState();
public Inventory getInventory() throws IllegalStateException {
InventoryHolder container;
try {
container = (InventoryHolder) this.loc.getBlock().getState();
return container.getInventory();
} catch (Exception e) {
throw new IllegalStateException("Inventory doesn't exist anymore");
}
}
/**