Access check updated

This commit is contained in:
Svenja Reissaus 2018-09-03 12:11:03 -03:00
parent c2292d99fc
commit 6eccfa84f1
3 changed files with 14 additions and 11 deletions

@ -50,7 +50,7 @@ public abstract class FCommand extends MCommand<P> {
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;
}
}
@ -60,7 +60,7 @@ public abstract class FCommand extends MCommand<P> {
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;
}
}
@ -70,7 +70,7 @@ public abstract class FCommand extends MCommand<P> {
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;
}
}
@ -80,7 +80,7 @@ public abstract class FCommand extends MCommand<P> {
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;
}
}

@ -75,13 +75,15 @@ public class FactionsBlockListener implements Listener {
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;
}
@ -381,7 +383,7 @@ public class FactionsBlockListener implements Listener {
// 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);

@ -311,11 +311,11 @@ public class FactionsPlayerListener implements Listener {
}
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) {
@ -441,14 +441,14 @@ public class FactionsPlayerListener implements Listener {
}
}
}
// 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);
@ -532,6 +532,7 @@ public class FactionsPlayerListener implements Listener {
}
public void enableFly(FPlayer me) {
if (!P.p.getConfig().getBoolean("enable-faction-flight")) return;
if (P.p.getConfig().getBoolean("ffly.AutoEnable")) {
me.setFlying(true);