Fixes UOE

Former-commit-id: 5b595e356935abab69b7c051a3bc59ff6fc7b161 [formerly 3d78290ad3f8b4a0a96d75b026a3c70bf63089c4]
Former-commit-id: 73cceef1830fa3ca39ec2d87c6b86fab9bf9fc2e
This commit is contained in:
cakoyo authored and GitHub committed 2019-04-28 11:22:24 +08:00
1 parent 72355920fa
commit f99f705432
1 file changed
+7 -2
@@ -594,6 +594,7 @@ public class QS implements CommandExecutor{
sender.sendMessage(MsgUtil.getMessage("command.cleaning"));
Iterator<Shop> shIt = plugin.getShopManager().getShopIterator();
int i = 0;
java.util.ArrayList<Shop> 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;