From efced89eb1b6910ec24ca297ef3d71aae7234573 Mon Sep 17 00:00:00 2001 From: Eric Date: Sun, 30 Jul 2017 17:58:56 +0200 Subject: [PATCH] Fixed ConcurrentModificationException (again) --- src/main/java/de/epiceric/shopchest/ShopChest.java | 3 +-- src/main/java/de/epiceric/shopchest/utils/ShopUtils.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/ShopChest.java b/src/main/java/de/epiceric/shopchest/ShopChest.java index d17d8cc..2a1b9fa 100644 --- a/src/main/java/de/epiceric/shopchest/ShopChest.java +++ b/src/main/java/de/epiceric/shopchest/ShopChest.java @@ -205,8 +205,7 @@ public class ShopChest extends JavaPlugin { if (database != null) { for (Shop shop : shopUtils.getShops()) { - shop.removeHologram(); - shop.removeItem(); + shopUtils.removeShop(shop, false); debug("Removed shop (#" + shop.getID() + ")"); } diff --git a/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java b/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java index 40c4cb4..9b78364 100644 --- a/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java +++ b/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java @@ -13,6 +13,7 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.util.Vector; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -23,7 +24,6 @@ import java.util.UUID; public class ShopUtils { private final HashMap shopLocation = new HashMap<>(); - private final Collection shopLocationValues = Collections.unmodifiableCollection(shopLocation.values()); private final HashMap playerLocation = new HashMap<>(); private final ShopChest plugin; @@ -58,7 +58,7 @@ public class ShopUtils { * @return Read-only collection of all shops, may contain duplicates */ public Collection getShops() { - return shopLocationValues; + return Collections.unmodifiableCollection(new ArrayList<>(shopLocation.values())); } /**