Added leader permission bypass for new access

This commit is contained in:
ProSavage 2019-04-01 16:45:37 -05:00
parent 18d3c4ec4a
commit e13c60843a

View File

@ -18,7 +18,7 @@ import com.massivecraft.factions.util.MultiversionMaterials;
import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; 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.TL;
import com.massivecraft.factions.zcore.util.TagUtil; import com.massivecraft.factions.zcore.util.TagUtil;
import com.massivecraft.factions.zcore.util.TextUtil; 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.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.util.NumberConversions;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
@ -891,25 +890,27 @@ public class FactionsPlayerListener implements Listener {
/// <param name="loc">The World location where the action is being executed</param> /// <param name="loc">The World location where the action is being executed</param>
/// <param name="myFaction">The faction of the player being checked</param> /// <param name="myFaction">The faction of the player being checked</param>
/// <param name="access">The current's faction access permission for the action</param> /// <param name="access">The current's faction access permission for the action</param>
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; boolean doPain = pain && Conf.handleExploitInteractionSpam;
if (access != null && access != Access.UNDEFINED) { if (access != null && access != Access.UNDEFINED) {
// TODO: Update this once new access values are added other than just allow / deny. // TODO: Update this once new access values are added other than just allow / deny.
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty()); boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) return true; if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId())))
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) { return true;
me.msg("<b>You can't do that in this territory, it is owned by: " + myFaction.getOwnerListString(loc)); else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
me.msg("<b>You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc));
if (doPain) { if (doPain) {
player.damage(Conf.actionDeniedPainAmount); player.damage(Conf.actionDeniedPainAmount);
} }
return false; return false;
} else if (!landOwned && access == Access.ALLOW) return true; } else if (!landOwned && access == Access.ALLOW) return true;
else { 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; 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; return false;
} }
/// <summary> /// <summary>