Skip to content

Commit

Permalink
release: 1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Sep 11, 2023
1 parent dac3ee8 commit 0e056bf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pluginVersion=1.3.3
pluginVersion=1.3.4
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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;
}
}

0 comments on commit 0e056bf

Please sign in to comment.