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:
parent
5e78c5efb7
commit
1e5eccc25b
@ -396,12 +396,17 @@ public class QS implements CommandExecutor {
|
||||
int i = 0;
|
||||
while (shIt.hasNext()) {
|
||||
Shop shop = shIt.next();
|
||||
if (shop.getLocation().getWorld() != null && shop.isSelling() && shop.getRemainingStock() == 0 && shop instanceof ContainerShop) {
|
||||
ContainerShop cs = (ContainerShop) shop;
|
||||
if (cs.isDoubleShop())
|
||||
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++;
|
||||
|
||||
try {
|
||||
if (shop.getLocation().getWorld() != null && shop.isSelling() && shop.getRemainingStock() == 0 && shop instanceof ContainerShop) {
|
||||
ContainerShop cs = (ContainerShop) shop;
|
||||
if (cs.isDoubleShop())
|
||||
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();
|
||||
|
@ -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();
|
||||
return container.getInventory();
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user