Fixed ConcurrentModificationException (again)

This commit is contained in:
Eric 2017-07-30 17:58:56 +02:00
parent c230257676
commit efced89eb1
2 changed files with 3 additions and 4 deletions

View File

@ -205,8 +205,7 @@ public class ShopChest extends JavaPlugin {
if (database != null) { if (database != null) {
for (Shop shop : shopUtils.getShops()) { for (Shop shop : shopUtils.getShops()) {
shop.removeHologram(); shopUtils.removeShop(shop, false);
shop.removeItem();
debug("Removed shop (#" + shop.getID() + ")"); debug("Removed shop (#" + shop.getID() + ")");
} }

View File

@ -13,6 +13,7 @@ import org.bukkit.inventory.InventoryHolder;
import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -23,7 +24,6 @@ import java.util.UUID;
public class ShopUtils { public class ShopUtils {
private final HashMap<Location, Shop> shopLocation = new HashMap<>(); private final HashMap<Location, Shop> shopLocation = new HashMap<>();
private final Collection<Shop> shopLocationValues = Collections.unmodifiableCollection(shopLocation.values());
private final HashMap<UUID, Location> playerLocation = new HashMap<>(); private final HashMap<UUID, Location> playerLocation = new HashMap<>();
private final ShopChest plugin; private final ShopChest plugin;
@ -58,7 +58,7 @@ public class ShopUtils {
* @return Read-only collection of all shops, may contain duplicates * @return Read-only collection of all shops, may contain duplicates
*/ */
public Collection<Shop> getShops() { public Collection<Shop> getShops() {
return shopLocationValues; return Collections.unmodifiableCollection(new ArrayList<>(shopLocation.values()));
} }
/** /**