Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit e13c608

Browse files
committed
Added leader permission bypass for new access
1 parent 18d3c4e commit e13c608

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.massivecraft.factions.util.VisualizeUtil;
1919
import com.massivecraft.factions.zcore.fperms.Access;
2020
import com.massivecraft.factions.zcore.fperms.PermissableAction;
21-
import com.massivecraft.factions.zcore.persist.*;
21+
import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
2222
import com.massivecraft.factions.zcore.util.TL;
2323
import com.massivecraft.factions.zcore.util.TagUtil;
2424
import com.massivecraft.factions.zcore.util.TextUtil;
@@ -40,7 +40,6 @@
4040
import org.bukkit.event.inventory.InventoryCloseEvent;
4141
import org.bukkit.event.inventory.InventoryDragEvent;
4242
import org.bukkit.event.player.*;
43-
import org.bukkit.util.NumberConversions;
4443

4544
import java.util.*;
4645
import java.util.logging.Level;
@@ -891,25 +890,27 @@ public int increment() {
891890
/// <param name="loc">The World location where the action is being executed</param>
892891
/// <param name="myFaction">The faction of the player being checked</param>
893892
/// <param name="access">The current's faction access permission for the action</param>
894-
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean pain) {
893+
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) {
895894
boolean doPain = pain && Conf.handleExploitInteractionSpam;
896895
if (access != null && access != Access.UNDEFINED) {
897896
// TODO: Update this once new access values are added other than just allow / deny.
898-
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
899-
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) return true;
900-
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
901-
me.msg("<b>You can't do that in this territory, it is owned by: " + myFaction.getOwnerListString(loc));
897+
boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
898+
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId())))
899+
return true;
900+
else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
901+
me.msg("<b>You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc));
902902
if (doPain) {
903903
player.damage(Conf.actionDeniedPainAmount);
904904
}
905905
return false;
906906
} else if (!landOwned && access == Access.ALLOW) return true;
907907
else {
908-
me.msg("You cannot " + action + " in the territory of " + myFaction.getTag(me.getFaction()));
908+
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
909909
return false;
910910
}
911911
}
912-
me.msg("You cannot " + action + " in the territory of " + myFaction.getTag(me.getFaction()));
912+
if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true;
913+
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
913914
return false;
914915
}
915916
/// <summary>

0 commit comments

Comments
 (0)