From d44e30b625b2ca4018a98bbc3b4940f91bfe3b8e Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 29 Apr 2017 14:37:52 +0200 Subject: [PATCH] Improved support for GriefPrevention Now checks if the claim where the shop is located allows container access for the player. If there is no claim, shop creation is allowed (except it has been denied by other plugins) --- .../shopchest/listeners/ChestProtectListener.java | 6 +++++- .../shopchest/listeners/ShopInteractListener.java | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java index a46ae70..b33ad60 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java @@ -20,6 +20,7 @@ import de.epiceric.shopchest.shop.Shop; import de.epiceric.shopchest.utils.Permissions; import de.epiceric.shopchest.utils.ShopUtils; import de.epiceric.shopchest.utils.Utils; +import me.ryanhamshire.GriefPrevention.Claim; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -212,7 +213,10 @@ public class ChestProtectListener implements Listener { } if (externalPluginsAllowed && plugin.hasGriefPrevention() && config.enable_griefprevention_integration) { - externalPluginsAllowed &= plugin.getGriefPrevention().allowBuild(p, b.getLocation()) == null; + Claim claim = plugin.getGriefPrevention().dataStore.getClaimAt(b.getLocation(), false, null); + if (claim != null) { + externalPluginsAllowed &= claim.allowContainers(p) == null; + } } if (externalPluginsAllowed || p.hasPermission(Permissions.EXTEND_PROTECTED)) { diff --git a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java index 84b6ee0..4beca6d 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java @@ -30,6 +30,7 @@ import de.epiceric.shopchest.utils.Permissions; import de.epiceric.shopchest.utils.ShopUtils; import de.epiceric.shopchest.utils.Utils; import fr.xephi.authme.AuthMe; +import me.ryanhamshire.GriefPrevention.Claim; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.EconomyResponse; import org.bukkit.Bukkit; @@ -231,11 +232,15 @@ public class ShopInteractListener implements Listener { if (externalPluginsAllowed && plugin.hasGriefPrevention() && config.enable_griefprevention_integration) { plugin.debug("Checking if GriefPrevention allows shop creation..."); - String gpDenyReason = ""; + String gpDenyReason = null; for (Location loc : chestLocations) { if (loc != null) { - gpDenyReason = plugin.getGriefPrevention().allowBuild(p, loc); - externalPluginsAllowed &= gpDenyReason == null; + Claim claim = plugin.getGriefPrevention().dataStore.getClaimAt(loc, false, null); + if (claim != null) { + plugin.debug("Checking if claim allows container access"); + gpDenyReason = claim.allowContainers(p); + externalPluginsAllowed &= gpDenyReason == null; + } } }