From 4531da8190902926b04da0dc3b18bfc7e22b8831 Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Sat, 10 Mar 2018 16:26:18 -0800 Subject: [PATCH] Move f perm checks up --- .../listeners/FactionsPlayerListener.java | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 377d6476..4ccead8b 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -251,6 +251,7 @@ public class FactionsPlayerListener implements Listener { } if (!canPlayerUseBlock(player, block, false)) { + System.out.println("Cancelling " + player.getName() + " " + block.getType().name()); event.setCancelled(true); if (Conf.handleExploitInteractionSpam) { String name = player.getName(); @@ -318,6 +319,11 @@ public class FactionsPlayerListener implements Listener { return true; } + Access access = otherFaction.getAccess(me, PermissableAction.ITEM); + if (access != null && access != Access.UNDEFINED) { + return access == Access.ALLOW; + } + if (otherFaction.hasPlayersOnline()) { if (!Conf.territoryDenyUseageMaterials.contains(material)) { return true; // Item isn't one we're preventing for online factions. @@ -363,13 +369,6 @@ public class FactionsPlayerListener implements Listener { Faction myFaction = me.getFaction(); Relation rel = myFaction.getRelationTo(otherFaction); - - Access access = otherFaction.getAccess(me, PermissableAction.ITEM); - if (access != null && access != Access.UNDEFINED) { - // TODO: Update this once new access values are added other than just allow / deny. - return access == Access.ALLOW; - } - // Cancel if we are not in our own territory if (rel.confDenyUseage()) { if (!justCheck) { @@ -414,23 +413,6 @@ public class FactionsPlayerListener implements Listener { return true; } - // Dupe fix. - Faction myFaction = me.getFaction(); - Relation rel = myFaction.getRelationTo(otherFaction); - if (!rel.isMember() || !otherFaction.playerHasOwnershipRights(me, loc) && player.getItemInHand() != null) { - switch (player.getItemInHand().getType()) { - case CHEST: - case SIGN_POST: - case TRAPPED_CHEST: - case SIGN: - case WOOD_DOOR: - case IRON_DOOR: - return false; - default: - break; - } - } - PermissableAction action = null; switch (block.getType()) { @@ -468,6 +450,23 @@ public class FactionsPlayerListener implements Listener { return false; } + // Dupe fix. + Faction myFaction = me.getFaction(); + Relation rel = myFaction.getRelationTo(otherFaction); + if (!rel.isMember() || !otherFaction.playerHasOwnershipRights(me, loc) && player.getItemInHand() != null) { + switch (player.getItemInHand().getType()) { + case CHEST: + case SIGN_POST: + case TRAPPED_CHEST: + case SIGN: + case WOOD_DOOR: + case IRON_DOOR: + return false; + default: + break; + } + } + // We only care about some material types. if (otherFaction.hasPlayersOnline()) { if (!Conf.territoryProtectedMaterials.contains(material)) {