mirror of
https://github.com/EpicEricEE/ShopChest.git
synced 2024-11-28 21:45:47 +01:00
Change method of getting loaded chunks
This commit is contained in:
parent
6d16b39597
commit
4a907ee309
@ -5,10 +5,8 @@ import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@ -195,12 +193,10 @@ public class ShopChestImpl extends ShopChest {
|
||||
}
|
||||
);
|
||||
|
||||
List<Chunk> chunks = new ArrayList<>();
|
||||
for (World world : getServer().getWorlds()) {
|
||||
chunks.addAll(Arrays.asList(world.getLoadedChunks()));
|
||||
}
|
||||
Chunk[] chunks = getServer().getWorlds().stream().map(World::getLoadedChunks)
|
||||
.flatMap(Stream::of).toArray(Chunk[]::new);
|
||||
|
||||
((ShopManagerImpl) getShopManager()).loadShops(chunks.toArray(new Chunk[chunks.size()]),
|
||||
((ShopManagerImpl) getShopManager()).loadShops(chunks,
|
||||
shops -> {
|
||||
getServer().getPluginManager().callEvent(new ShopLoadedEvent(shops));
|
||||
Logger.info("Loaded {0} shops from the database", shops.size());
|
||||
|
@ -1,18 +1,17 @@
|
||||
package de.epiceric.shopchest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@ -235,12 +234,10 @@ public class ShopManagerImpl implements ShopManager {
|
||||
|
||||
@Override
|
||||
public void reloadShops(Consumer<Integer> callback, Consumer<Throwable> errorCallback) {
|
||||
List<Chunk> chunks = new ArrayList<>();
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
chunks.addAll(Arrays.asList(world.getLoadedChunks()));
|
||||
}
|
||||
Chunk[] chunks = plugin.getServer().getWorlds().stream().map(World::getLoadedChunks)
|
||||
.flatMap(Stream::of).toArray(Chunk[]::new);
|
||||
|
||||
loadShops(chunks.toArray(new Chunk[chunks.size()]),
|
||||
loadShops(chunks,
|
||||
shops -> callback.accept(shops.size()),
|
||||
errorCallback
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user