From 1473c4bd604ec0cc9c4e2052455e2cc6cffed729 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Sat, 16 Nov 2019 15:25:09 +0800 Subject: [PATCH] Update two apis Former-commit-id: b30c922ec4fc74c81ee6d55f34ec123bb7cb1c66 [formerly 25c5c37ddc47643f768fdc269a44d32790ec1063] Former-commit-id: 40d1eed09d3aac9c2ed9db6d0862c5efd8900516 --- .../maxgamer/quickshop/Shop/ShopManager.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index af2913600..bc0479ec3 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -25,6 +25,7 @@ import java.util.*; import java.util.Map.Entry; import java.util.concurrent.CopyOnWriteArraySet; import java.util.logging.Level; +import java.util.stream.Collectors; /** * Manage a lot of shops. @@ -969,20 +970,18 @@ public class ShopManager { /** * Get a players all shops. * @param playerUUID The player's uuid. - * @param ignoreUnlimitedShop Set we should ignore unlimited to get. * @return The list have this player's all shops. */ - public @NotNull List getPlayerAllShops(@NotNull UUID playerUUID, boolean ignoreUnlimitedShop){ - List collectedShops = new ArrayList<>(); - for(Shop shop : getAllShops()){ - if(!shop.getOwner().equals(playerUUID)){ - continue; - } - if(ignoreUnlimitedShop && shop.isUnlimited()){ - continue; - } - collectedShops.add(shop); - } - return collectedShops; + public @NotNull List getPlayerAllShops(@NotNull UUID playerUUID){ + return getAllShops().stream().filter(shop -> shop.getOwner().equals(playerUUID)).collect(Collectors.toList()); + } + + /** + * Get the all shops in the world. + * @param world The world you want get the shops. + * @return The list have this world all shops + */ + public @NotNull List getShopsInWorld(@NotNull World world){ + return getAllShops().stream().filter(shop -> shop.getLocation().getWorld().equals(world)).collect(Collectors.toList()); } }