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

Commit

Permalink
Access check updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Svenja Reissaus committed Sep 3, 2018
1 parent c2292d9 commit 6eccfa8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/massivecraft/factions/cmd/FCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public boolean hasAccess() {
if (this.actionPermission == null || this.fme == null) return false;
if (!this.fme.isAdminBypassing()) {
Access access = myFaction.getAccess(this.fme, this.actionPermission);
if (access != Access.ALLOW && this.fme.getRole() != Role.ADMIN) {
if (access == Access.DENY) {
return false;
}
}
Expand All @@ -60,7 +60,7 @@ public boolean hasAccess(boolean checkifAdmin) {
if (this.actionPermission == null || this.fme == null) return false;
if (!this.fme.isAdminBypassing() && checkifAdmin) {
Access access = myFaction.getAccess(this.fme, this.actionPermission);
if (access != Access.ALLOW && this.fme.getRole() != Role.ADMIN) {
if (access == Access.DENY) {
return false;
}
}
Expand All @@ -70,7 +70,7 @@ public boolean hasAccess(PermissableAction perm) {
if (this.permission == null || this.fme == null) return false;
if (!this.fme.isAdminBypassing()) {
Access access = myFaction.getAccess(this.fme, perm);
if (access != Access.ALLOW && this.fme.getRole() != Role.ADMIN) {
if (access == Access.DENY) {
return false;
}
}
Expand All @@ -80,7 +80,7 @@ public boolean hasAccess(PermissableAction perm, boolean checkifAdmin) {
if (this.permission == null || this.fme == null) return false;
if (!this.fme.isAdminBypassing() && checkifAdmin) {
Access access = myFaction.getAccess(this.fme, perm);
if (access != Access.ALLOW && this.fme.getRole() != Role.ADMIN) {
if (access == Access.DENY) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ public void onBlockBreak(BlockBreakEvent event) {
return;
}
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
Faction faction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
if (!fme.hasFaction()) {
return;
}
if (event.getBlock().getType() == P.p.MOB_SPANWER) {
if (!fme.isAdminBypassing()) {
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
// We don't want other factions to break blocks unless allowed
if (access == Access.DENY || (access != Access.ALLOW && fme.getFaction() != faction)) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
return;
}
Expand Down Expand Up @@ -381,7 +383,7 @@ public static boolean playerCanBuildDestroyBlock(Player player, Location locatio

// Check the permission just after making sure the land isn't owned by someone else to avoid bypass.
Access access = otherFaction.getAccess(me, PermissableAction.fromString(action));
if (access != Access.ALLOW && me.getRole() != Role.ADMIN) {
if (access == Access.DENY || (access != Access.ALLOW && me.getFaction() != otherFaction)) {
// TODO: Update this once new access values are added other than just allow / deny.
if (access == Access.DENY) {
me.msg(TL.GENERIC_NOPERMISSION, action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,11 @@ public static boolean canPlayerUseBlock(Player player, Block block, boolean just
}

Access access = otherFaction.getAccess(me, action);
if (access != Access.ALLOW && me.getRole() != Role.ADMIN) {
if (access == Access.DENY || (access != Access.ALLOW && me.getFaction() != otherFaction)) {
// TODO: Update this once new access values are added other than just allow / deny.
if ((myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && myFaction.getOwnerListString(loc).contains(player.getName()))) {
if ((myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && myFaction.isPlayerInOwnerList(me, loc))) {
return true;
} else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.getOwnerListString(loc).contains(player.getName())) {
} else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.isPlayerInOwnerList(me, loc)) {
me.msg("<b>You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc));
return false;
} else if (access == Access.DENY) {
Expand Down Expand Up @@ -441,14 +441,14 @@ public void run() {
}
}
}

// We might enable flight on player join just so he doesn't have to /f fly even if the ffly.AutoEnable option is enabled:
enableFly(me);

fallMap.put(me.getPlayer(), false);
Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, new Runnable() {
@Override
public void run() {
fallMap.remove(me.getPlayer());

}
}, 180L);

Expand Down Expand Up @@ -532,6 +532,7 @@ public String parseAllPlaceholders(String string, Faction faction, Player player
}

public void enableFly(FPlayer me) {
if (!P.p.getConfig().getBoolean("enable-faction-flight")) return;
if (P.p.getConfig().getBoolean("ffly.AutoEnable")) {

me.setFlying(true);
Expand Down

0 comments on commit 6eccfa8

Please sign in to comment.