diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/ProtectionListenerBase.java b/src/main/java/org/maxgamer/quickshop/Listeners/ProtectionListenerBase.java index f42a602e8..d9e53f4e3 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/ProtectionListenerBase.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/ProtectionListenerBase.java @@ -46,7 +46,7 @@ public class ProtectionListenerBase { */ @Nullable public Shop getShopPlayer(@NotNull Location location, boolean includeAttached) { - return plugin.getShopManager().getShop(location); + return includeAttached ? plugin.getShopManager().getShopIncludeAttached(location,false):plugin.getShopManager().getShop(location); } /** @@ -58,7 +58,7 @@ public class ProtectionListenerBase { */ @Nullable public Shop getShopNature(@NotNull Location location, boolean includeAttached) { - return plugin.getShopManager().getShop(location); + return includeAttached ? plugin.getShopManager().getShopIncludeAttached(location,false):plugin.getShopManager().getShop(location); } } diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index 7f9f8de78..487b50ec6 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -318,13 +318,24 @@ public class ShopManager { * @return The shop at that location */ public @Nullable Shop getShopIncludeAttached(@Nullable Location loc) { + return getShopIncludeAttached(loc,true); + } + + /** + * Gets a shop in a specific location Include the attached shop, e.g DoubleChest shop. + * + * @param loc The location to get the shop from + * @param useCache whether to use cache + * @return The shop at that location + */ + public @Nullable Shop getShopIncludeAttached(@Nullable Location loc,boolean useCache) { if (loc == null) { Util.debugLog("Location is null."); return null; } if (this.useFastShopSearchAlgorithm) { - return getShopIncludeAttached_Fast(loc, false); + return getShopIncludeAttached_Fast(loc, false,useCache); } else { return getShopIncludeAttached_Classic(loc); } @@ -1014,6 +1025,10 @@ public class ShopManager { } private @Nullable Shop getShopIncludeAttached_Fast(@NotNull Location loc, boolean fromAttach) { + return getShopIncludeAttached_Fast(loc,fromAttach,true); + } + + private @Nullable Shop getShopIncludeAttached_Fast(@NotNull Location loc, boolean fromAttach,boolean useCache) { Shop shop; //Try to get it directly shop = getShop(loc); @@ -1038,7 +1053,7 @@ public class ShopManager { } } //add cache if using - if(plugin.getShopCache()!=null) { + if(plugin.getShopCache()!=null&&useCache) { plugin.getShopCache().setCache(loc, shop); }