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)
This commit is contained in:
Eric 2017-04-29 14:37:52 +02:00
parent 0f4f421f76
commit d44e30b625
2 changed files with 13 additions and 4 deletions

View File

@ -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)) {

View File

@ -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,13 +232,17 @@ 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);
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;
}
}
}
if (!externalPluginsAllowed) denyReason = "GriefPrevention (" + gpDenyReason + ")";
}