diff --git a/src/main/java/org/maxgamer/quickshop/Command/QS.java b/src/main/java/org/maxgamer/quickshop/Command/QS.java index 4568dbbba..30706138c 100644 --- a/src/main/java/org/maxgamer/quickshop/Command/QS.java +++ b/src/main/java/org/maxgamer/quickshop/Command/QS.java @@ -594,6 +594,7 @@ public class QS implements CommandExecutor{ sender.sendMessage(MsgUtil.getMessage("command.cleaning")); Iterator shIt = plugin.getShopManager().getShopIterator(); int i = 0; + java.util.ArrayList pendingRemoval = new java.util.ArrayList<>(); while (shIt.hasNext()) { Shop shop = shIt.next(); @@ -603,14 +604,18 @@ public class QS implements CommandExecutor{ 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. + pendingRemoval.add(shop); // 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 + pendingRemoval.add(shop); // The shop is not there anymore, remove it } } + + for (Shop shop : pendingRemoval) + plugin.getShopManager().removeShop(shop); + MsgUtil.clean(); sender.sendMessage(MsgUtil.getMessage("command.cleaned", "" + i)); return;