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,12 +396,17 @@ public class QS implements CommandExecutor {
int i = 0; int i = 0;
while (shIt.hasNext()) { while (shIt.hasNext()) {
Shop shop = shIt.next(); Shop shop = shIt.next();
if (shop.getLocation().getWorld() != null && shop.isSelling() && shop.getRemainingStock() == 0 && shop instanceof ContainerShop) {
ContainerShop cs = (ContainerShop) shop; try {
if (cs.isDoubleShop()) if (shop.getLocation().getWorld() != null && shop.isSelling() && shop.getRemainingStock() == 0 && shop instanceof ContainerShop) {
continue; ContainerShop cs = (ContainerShop) shop;
shIt.remove(); // Is selling, but has no stock, and is a chest shop, but is not a double shop. Can be deleted safely. if (cs.isDoubleShop())
i++; continue;
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(); MsgUtil.clean();

View File

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