mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-12-22 00:51:46 +00:00
Make ShopUtils#getShops() return a new copy
ShopUtils#getShopsCopy() is now deprecated
This commit is contained in:
parent
443cab6df5
commit
30a2b8aefc
@ -249,7 +249,7 @@ public class ShopChest extends JavaPlugin {
|
||||
shopCreationThreadPool.shutdown();
|
||||
}
|
||||
|
||||
for (Shop shop : shopUtils.getShopsCopy()) {
|
||||
for (Shop shop : shopUtils.getShops()) {
|
||||
shopUtils.removeShop(shop, false);
|
||||
debug("Removed shop (#" + shop.getID() + ")");
|
||||
}
|
||||
|
@ -202,9 +202,8 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
plugin.getUpdater().restart();
|
||||
|
||||
// Remove all shops
|
||||
Iterator<Shop> iter = shopUtils.getShops().iterator();
|
||||
while (iter.hasNext()) {
|
||||
shopUtils.removeShop(iter.next(), false);
|
||||
for (Shop shop : shopUtils.getShops()) {
|
||||
shopUtils.removeShop(shop, false);
|
||||
}
|
||||
|
||||
Chunk[] loadedChunks = Bukkit.getWorlds().stream().map(World::getLoadedChunks)
|
||||
|
@ -53,7 +53,7 @@ public class AreaShopListener implements Listener {
|
||||
private void removeShopsInRegion(GeneralRegion generalRegion) {
|
||||
if (!plugin.hasWorldGuard()) return;
|
||||
|
||||
for (Shop shop : plugin.getShopUtils().getShopsCopy()) {
|
||||
for (Shop shop : plugin.getShopUtils().getShops()) {
|
||||
if (!shop.getLocation().getWorld().getName().equals(generalRegion.getWorldName())) continue;
|
||||
|
||||
for (IWrappedRegion r : WorldGuardWrapper.getInstance().getRegions(shop.getLocation())) {
|
||||
|
@ -70,7 +70,7 @@ public class BentoBoxListener implements Listener {
|
||||
if (!Config.enableBentoBoxIntegration)
|
||||
return;
|
||||
|
||||
Collection<Shop> shops = plugin.getShopUtils().getShopsCopy();
|
||||
Collection<Shop> shops = plugin.getShopUtils().getShops();
|
||||
for (Shop shop : shops) {
|
||||
if (!shop.getLocation().getWorld().getName().equals(world.getName())) {
|
||||
continue;
|
||||
|
@ -65,23 +65,24 @@ public class ShopUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all shops
|
||||
* Do not use for removing while iteration!
|
||||
* Get a collection of all loaded shops
|
||||
* <p>
|
||||
* This collection is safe to use for looping over and removing shops.
|
||||
*
|
||||
* @see #getShopsCopy()
|
||||
* @return Read-only collection of all shops, may contain duplicates
|
||||
* @return Read-only collection of all shops, may contain duplicates for double chests
|
||||
*/
|
||||
public Collection<Shop> getShops() {
|
||||
return shopLocationValues;
|
||||
return Collections.unmodifiableCollection(new ArrayList<>(shopLocationValues));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all shops
|
||||
* Same as {@link #getShops()} but this is safe to remove while iterating
|
||||
*
|
||||
* @see #getShops()
|
||||
* @return Copy of collection of all shops, may contain duplicates
|
||||
* @deprecated Use {@link #getShops()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public Collection<Shop> getShopsCopy() {
|
||||
return new ArrayList<>(getShops());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user