Default permission check for build on interact

This commit is contained in:
SvenjaReißaus 2019-03-18 22:20:51 -05:00
parent 4608f26975
commit 11b2eff79c
No known key found for this signature in database
GPG Key ID: E5494A03FA36D54B
2 changed files with 5 additions and 2 deletions

View File

@ -18,7 +18,7 @@ import com.massivecraft.factions.util.MultiversionMaterials;
import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
import com.massivecraft.factions.zcore.persist.*;
import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TagUtil;
import com.massivecraft.factions.zcore.util.TextUtil;
@ -872,13 +872,16 @@ public class FactionsPlayerListener implements Listener {
Block block = event.getClickedBlock();
Player player = event.getPlayer();
FLocation loc = new FLocation(block.getLocation());
Faction faction = MemoryBoard.getInstance().getFactionAt(loc);
FPlayer fplayer = MemoryFPlayers.getInstance().getByPlayer(player);
// Check if the material is bypassing protection
if (Conf.territoryBypasssProtectedMaterials.contains(block.getType())) return;
if (block == null) return; // clicked in air, apparently
if (!FactionsBlockListener.playerCanBuildDestroyBlock(player, block.getLocation(), "build", false)
if (!CheckPlayerAccess(player, fplayer, loc, faction, faction.getAccess(fplayer, PermissableAction.BUILD), PermissableAction.BUILD, (faction.getAccess(fplayer, PermissableAction.PAIN_BUILD) == Access.ALLOW))
|| !canPlayerUseBlock(player, block, false)
|| !playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) {
event.setCancelled(true);