From ddaa2bdbfc5a1ac7dc524145effd4c0ee588f098 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Mon, 21 Mar 2016 20:36:09 +0100 Subject: [PATCH] Update to GriefPrevention 13.9.1 --- .../integration/GriefPreventionBarrel.java | 65 ++++++++++--------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/src/com/dre/brewery/integration/GriefPreventionBarrel.java b/src/com/dre/brewery/integration/GriefPreventionBarrel.java index a992d16..bbd8978 100644 --- a/src/com/dre/brewery/integration/GriefPreventionBarrel.java +++ b/src/com/dre/brewery/integration/GriefPreventionBarrel.java @@ -1,42 +1,47 @@ package com.dre.brewery.integration; +import com.dre.brewery.P; +import me.ryanhamshire.GriefPrevention.Claim; +import me.ryanhamshire.GriefPrevention.GriefPrevention; +import me.ryanhamshire.GriefPrevention.PlayerData; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import com.dre.brewery.P; -import me.ryanhamshire.GriefPrevention.Configuration.WorldConfig; -import me.ryanhamshire.GriefPrevention.GriefPrevention; -import me.ryanhamshire.GriefPrevention.Messages; -import me.ryanhamshire.GriefPrevention.PlayerData; -import me.ryanhamshire.GriefPrevention.TextMode; - public class GriefPreventionBarrel { - public static boolean checkAccess(Player player, Block sign) { - WorldConfig wc = GriefPrevention.instance.getWorldCfg(player.getWorld()); - /*if (!wc.Enabled()) { - return true; - }*/ + static P brewery = P.p; + static GriefPrevention griefPrevention = GriefPrevention.instance; - PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getName()); + public static boolean checkAccess(Player player, Block sign) { + PlayerData playerData = griefPrevention.dataStore.getPlayerData(player.getUniqueId()); - // block container use during pvp combat - if (playerData.inPvpCombat() && wc.getPvPBlockContainers()) { - GriefPrevention.sendMessage(player, TextMode.Err, Messages.PvPNoContainers); - return false; - } + if (!griefPrevention.claimsEnabledForWorld(player.getWorld()) || playerData.ignoreClaims || !griefPrevention.config_claims_preventTheft) { + return true; + } - // check permissions for the claim the Barrel is in - if (wc.getContainersRules().Allowed(sign.getLocation(), player, true).Denied()) { - P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess")); - return false; - } + // block container use during pvp combat + if (playerData.inPvpCombat()) { + brewery.msg(player, brewery.languageReader.get("Error_NoBarrelAccess")); + return false; + } + + // check permissions for the claim the Barrel is in + Claim claim = griefPrevention.dataStore.getClaimAt(sign.getLocation(), false, playerData.lastClaim); + if (claim != null) { + playerData.lastClaim = claim; + String noContainersReason = claim.allowContainers(player); + if (noContainersReason != null) { + brewery.msg(player, brewery.languageReader.get("Error_NoBarrelAccess")); + return false; + } + } + + // drop any pvp protection, as the player opens a barrel + if (playerData.pvpImmune) { + playerData.pvpImmune = false; + } + + return true; + } - // drop any pvp protection, as the player opens a barrel - if (playerData.pvpImmune) { - playerData.pvpImmune = false; - GriefPrevention.sendMessage(player, TextMode.Warn, Messages.PvPImmunityEnd); - } - return true; - } }