diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index d4b57787..8502fd0f 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -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.*; +import com.massivecraft.factions.zcore.persist.MemoryFPlayer; import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TagUtil; import com.massivecraft.factions.zcore.util.TextUtil; @@ -40,7 +40,6 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.player.*; -import org.bukkit.util.NumberConversions; import java.util.*; import java.util.logging.Level; @@ -891,25 +890,27 @@ public class FactionsPlayerListener implements Listener { /// The World location where the action is being executed /// The faction of the player being checked /// The current's faction access permission for the action - private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean pain) { + private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) { boolean doPain = pain && Conf.handleExploitInteractionSpam; if (access != null && access != Access.UNDEFINED) { // TODO: Update this once new access values are added other than just allow / deny. - boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty()); - if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) return true; - else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) { - me.msg("You can't do that in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); + boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty()); + if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId()))) + return true; + else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) { + me.msg("You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc)); if (doPain) { player.damage(Conf.actionDeniedPainAmount); } return false; } else if (!landOwned && access == Access.ALLOW) return true; else { - me.msg("You cannot " + action + " in the territory of " + myFaction.getTag(me.getFaction())); + me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction())); return false; } } - me.msg("You cannot " + action + " in the territory of " + myFaction.getTag(me.getFaction())); + if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true; + me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction())); return false; } ///