diff --git a/gradle.properties b/gradle.properties index 8577a83..1dbae1d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -pluginVersion=1.3.3 +pluginVersion=1.3.4 diff --git a/src/main/java/io/th0rgal/protectionlib/compatibilities/GriefPreventionCompat.java b/src/main/java/io/th0rgal/protectionlib/compatibilities/GriefPreventionCompat.java index c03ae1c..045f4de 100644 --- a/src/main/java/io/th0rgal/protectionlib/compatibilities/GriefPreventionCompat.java +++ b/src/main/java/io/th0rgal/protectionlib/compatibilities/GriefPreventionCompat.java @@ -1,7 +1,10 @@ package io.th0rgal.protectionlib.compatibilities; import io.th0rgal.protectionlib.ProtectionCompatibility; +import me.ryanhamshire.GriefPrevention.Claim; +import me.ryanhamshire.GriefPrevention.ClaimPermission; import me.ryanhamshire.GriefPrevention.GriefPrevention; +import me.ryanhamshire.GriefPrevention.PlayerData; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -20,7 +23,7 @@ public GriefPreventionCompat(JavaPlugin mainPlugin, Plugin plugin) { */ @Override public boolean canBuild(Player player, Location target) { - return GriefPrevention.instance.allowBuild(player, target) == null; + return checkPermission(player, target, ClaimPermission.Build); } /** @@ -30,7 +33,7 @@ public boolean canBuild(Player player, Location target) { */ @Override public boolean canBreak(Player player, Location target) { - return GriefPrevention.instance.allowBreak(player, target.getBlock(), target) == null; + return checkPermission(player, target, ClaimPermission.Build); } /** @@ -40,7 +43,7 @@ public boolean canBreak(Player player, Location target) { */ @Override public boolean canInteract(Player player, Location target) { - return GriefPrevention.instance.allowBuild(player, target) == null; + return checkPermission(player, target, ClaimPermission.Access); } /** @@ -50,6 +53,15 @@ public boolean canInteract(Player player, Location target) { */ @Override public boolean canUse(Player player, Location target) { - return GriefPrevention.instance.allowBuild(player, target) == null; + return checkPermission(player, target, ClaimPermission.Access); + } + + private boolean checkPermission(Player player, Location target, ClaimPermission permission) { + PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()); + Claim claim = GriefPrevention.instance.dataStore.getClaimAt(target, false, playerData.lastClaim); + if (playerData.ignoreClaims) return true; + + playerData.lastClaim = claim; + return claim.checkPermission(player, permission, null) == null; } }