From 0e056bf148ef6b33482e93447e82c1f4d520e5f2 Mon Sep 17 00:00:00 2001 From: Boy Date: Mon, 11 Sep 2023 11:47:16 +0200 Subject: [PATCH] release: 1.3.4 --- gradle.properties | 2 +- .../GriefPreventionCompat.java | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) 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; } }