From 709c1fe80d604e239adb5079f85d913c46846d0e Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 29 Apr 2013 12:48:11 +0200 Subject: [PATCH] Work on TerritoryAccess and permissions. --- src/com/massivecraft/factions/FPerm.java | 174 ++++++++---------- .../factions/TerritoryAccess.java | 77 ++------ .../factions/cmd/CmdFactionsClaim.java | 2 +- .../factions/cmd/CmdFactionsDisband.java | 2 +- .../factions/cmd/CmdFactionsInvite.java | 2 +- .../factions/cmd/CmdFactionsKick.java | 2 +- .../factions/cmd/CmdFactionsPerm.java | 2 +- .../factions/cmd/CmdFactionsSethome.java | 2 +- .../factions/cmd/CmdFactionsUnclaim.java | 2 +- .../factions/cmd/CmdFactionsUnclaimall.java | 2 +- .../factions/integration/Econ.java | 2 +- .../listeners/FactionsListenerMain.java | 52 +++--- 12 files changed, 132 insertions(+), 189 deletions(-) diff --git a/src/com/massivecraft/factions/FPerm.java b/src/com/massivecraft/factions/FPerm.java index ed356040..4c2df76a 100644 --- a/src/com/massivecraft/factions/FPerm.java +++ b/src/com/massivecraft/factions/FPerm.java @@ -2,19 +2,17 @@ package com.massivecraft.factions; import java.util.Arrays; import java.util.Collections; -import java.util.EnumSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; -import org.bukkit.command.CommandSender; - import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.UConf; import com.massivecraft.mcore.ps.PS; +import com.massivecraft.mcore.util.Txt; /** * Permissions that you (a player) may or may not have in the territory of a certain faction. @@ -26,21 +24,21 @@ public enum FPerm // ENUM // -------------------------------------------- // - BUILD("build", "edit the terrain", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY), - PAINBUILD("painbuild", "edit, take damage"), - DOOR("door", "use doors", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), - BUTTON("button", "use stone buttons", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), - LEVER("lever", "use levers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), - CONTAINER("container", "use containers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER), + BUILD(true, "build", "edit the terrain", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.ALLY), + PAINBUILD(true, "painbuild", "edit, take damage"), + DOOR(true, "door", "use doors", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), + BUTTON(true, "button", "use stone buttons", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), + LEVER(true, "lever", "use levers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), + CONTAINER(true, "container", "use containers", Rel.LEADER, Rel.OFFICER, Rel.MEMBER), - INVITE("invite", "invite players", Rel.LEADER, Rel.OFFICER), - KICK("kick", "kick members", Rel.LEADER, Rel.OFFICER), - SETHOME("sethome", "set the home", Rel.LEADER, Rel.OFFICER), - WITHDRAW("withdraw", "withdraw money", Rel.LEADER, Rel.OFFICER), - TERRITORY("territory", "claim or unclaim", Rel.LEADER, Rel.OFFICER), - ACCESS("access", "grant territory", Rel.LEADER, Rel.OFFICER), - DISBAND("disband", "disband the faction", Rel.LEADER), - PERMS("perms", "manage permissions", Rel.LEADER), + INVITE(false, "invite", "invite players", Rel.LEADER, Rel.OFFICER), + KICK(false, "kick", "kick members", Rel.LEADER, Rel.OFFICER), + SETHOME(false, "sethome", "set the home", Rel.LEADER, Rel.OFFICER), + WITHDRAW(false, "withdraw", "withdraw money", Rel.LEADER, Rel.OFFICER), + TERRITORY(false, "territory", "claim or unclaim", Rel.LEADER, Rel.OFFICER), + ACCESS(false, "access", "grant territory", Rel.LEADER, Rel.OFFICER), + DISBAND(false, "disband", "disband the faction", Rel.LEADER), + PERMS(false, "perms", "manage permissions", Rel.LEADER), // END OF LIST ; @@ -49,6 +47,9 @@ public enum FPerm // FIELDS // -------------------------------------------- // + private final boolean territoryPerm; + public boolean isTerritoryPerm() { return this.territoryPerm; } + private final String nicename; public String getNicename() { return this.nicename; } @@ -62,8 +63,9 @@ public enum FPerm // CONSTRUCT // -------------------------------------------- // - private FPerm(final String nicename, final String desc, final Rel... rels) + private FPerm(boolean territoryPerm, final String nicename, final String desc, final Rel... rels) { + this.territoryPerm = territoryPerm; this.nicename = nicename; this.desc = desc; @@ -120,7 +122,62 @@ public enum FPerm } // -------------------------------------------- // - // UTIL + // HAS? + // -------------------------------------------- // + + public String createDeniedMessage(UPlayer uplayer, Faction hostFaction) + { + String ret = Txt.parse("%s does not allow you to %s.", hostFaction.describeTo(uplayer, true), this.getDescription()); + if (Perm.ADMIN.has(uplayer.getPlayer())) + { + ret += Txt.parse("\nYou can bypass by using " + Factions.get().getOuterCmdFactions().cmdFactionsAdmin.getUseageTemplate(false)); + } + return ret; + } + + public boolean has(Faction faction, Faction hostFaction) + { + Rel rel = faction.getRelationTo(hostFaction); + return hostFaction.getPermittedRelations(this).contains(rel); + } + + public boolean has(UPlayer uplayer, Faction hostFaction, boolean verboose) + { + if (uplayer.isUsingAdminMode()) return true; + + Faction faction = uplayer.getFaction(); + if (this.has(faction, hostFaction)) return true; + + if (verboose) uplayer.sendMessage(this.createDeniedMessage(uplayer, hostFaction)); + + return false; + } + + public boolean has(UPlayer uplayer, PS ps, boolean verboose) + { + if (uplayer.isUsingAdminMode()) return true; + + TerritoryAccess ta = BoardColls.get().getTerritoryAccessAt(ps); + Faction hostFaction = ta.getHostFaction(ps); + + if (this.isTerritoryPerm()) + { + Boolean hasTerritoryAccess = ta.hasTerritoryAccess(uplayer); + if (hasTerritoryAccess != null) + { + if (verboose && !hasTerritoryAccess) + { + uplayer.sendMessage(this.createDeniedMessage(uplayer, hostFaction)); + } + return hasTerritoryAccess; + } + } + + return this.has(uplayer, hostFaction, verboose); + } + + // -------------------------------------------- // + // UTIL: ASCII // -------------------------------------------- // public static String getStateHeaders() @@ -160,82 +217,5 @@ public enum FPerm } return ret; } - - // Perms which apply strictly to granting territory access - // TODO: This should be a boolean field within the class itself! - private static final Set TerritoryPerms = EnumSet.of(BUILD, DOOR, BUTTON, LEVER, CONTAINER); - public boolean isTerritoryPerm() - { - return TerritoryPerms.contains(this); - } - - private static final String errorpattern = "%s does not allow you to %s."; - public boolean has(Object testSubject, Faction hostFaction, boolean informIfNot) - { - RelationParticipator rpSubject = null; - - if (testSubject instanceof CommandSender) - { - rpSubject = UPlayer.get(testSubject); - } - else if (testSubject instanceof RelationParticipator) - { - rpSubject = (RelationParticipator) testSubject; - } - else - { - return false; - } - - Rel rel = rpSubject.getRelationTo(hostFaction); - - // TODO: Create better description messages like: "You must at least be officer". - boolean ret = hostFaction.getPermittedRelations(this).contains(rel); - - if (rpSubject instanceof UPlayer && ret == false && ((UPlayer)rpSubject).isUsingAdminMode()) ret = true; - - if (!ret && informIfNot && rpSubject instanceof UPlayer) - { - UPlayer uplayer = (UPlayer)rpSubject; - uplayer.msg(errorpattern, hostFaction.describeTo(uplayer, true), this.getDescription()); - if (Perm.ADMIN.has(uplayer.getPlayer())) - { - uplayer.msg("You can bypass by using " + Factions.get().getOuterCmdFactions().cmdFactionsAdmin.getUseageTemplate(false)); - } - } - return ret; - } - public boolean has(Object testSubject, Faction hostFaction) - { - return this.has(testSubject, hostFaction, false); - } - public boolean has(Object testSubject, PS ps, boolean informIfNot) - { - TerritoryAccess access = BoardColls.get().getTerritoryAccessAt(ps); - - if (this.isTerritoryPerm()) - { - if (access.subjectHasAccess(testSubject)) return true; - if (access.subjectAccessIsRestricted(testSubject)) - { - if (informIfNot) - { - UPlayer notify = null; - if (testSubject instanceof CommandSender) - notify = UPlayer.get(testSubject); - else if (testSubject instanceof UPlayer) - notify = (UPlayer)testSubject; - if (notify != null) - notify.msg("This territory owned by your faction has restricted access."); - } - return false; - } - } - - return this.has(testSubject, BoardColls.get().getFactionAt(ps), informIfNot); - } - public boolean has(Object testSubject, PS ps) - { - return this.has(testSubject, ps, false); - } + } diff --git a/src/com/massivecraft/factions/TerritoryAccess.java b/src/com/massivecraft/factions/TerritoryAccess.java index 960a10c8..2b435b47 100644 --- a/src/com/massivecraft/factions/TerritoryAccess.java +++ b/src/com/massivecraft/factions/TerritoryAccess.java @@ -7,9 +7,6 @@ import java.util.LinkedHashSet; import java.util.Set; import java.util.TreeSet; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; @@ -199,66 +196,24 @@ public class TerritoryAccess { return this.isHostFactionAllowed() && this.getFactionIds().isEmpty() && this.getPlayerIds().isEmpty(); } + + // -------------------------------------------- // + // HAS CHECK + // -------------------------------------------- // - // TODO: This looks like an extractor in my eyes. - // TODO: Perhaps create a factionId extractor? - public boolean doesHostFactionMatch(Object testSubject) + // true means elevated access + // false means decreased access + // null means standard access + public Boolean hasTerritoryAccess(UPlayer uplayer) { - String factionId = null; - if (testSubject instanceof String) - { - factionId = (String)testSubject; - } - else if (testSubject instanceof CommandSender) - { - factionId = UPlayer.get(testSubject).getFactionId(); - } - else if (testSubject instanceof UPlayer) - { - factionId = ((UPlayer)testSubject).getFactionId(); - } - else if (testSubject instanceof Faction) - { - factionId = ((Faction)testSubject).getId(); - } - return this.getHostFactionId().equals(factionId); - } - - // -------------------------------------------- // - // DERPINGTON CHECKS - // -------------------------------------------- // - - // these return false if not granted explicit access, or true if granted explicit access (in FPlayer or Faction lists) - // they do not take into account hostFactionAllowed, which will need to be checked separately (as to not override FPerms which are denied for faction members and such) - public boolean subjectHasAccess(Object testSubject) - { - if (testSubject instanceof Player) - { - return fPlayerHasAccess(UPlayer.get(testSubject)); - } - else if (testSubject instanceof UPlayer) - { - return fPlayerHasAccess((UPlayer)testSubject); - } - else if (testSubject instanceof Faction) - { - return factionHasAccess((Faction)testSubject); - } - return false; - } - public boolean fPlayerHasAccess(UPlayer fplayer) - { - return this.isPlayerIdGranted(fplayer.getId()) || this.isFactionIdGranted(fplayer.getFaction().getId()); - } - public boolean factionHasAccess(Faction faction) - { - return this.isFactionIdGranted(faction.getId()); - } - - // this should normally only be checked after running subjectHasAccess() or fPlayerHasAccess() above to see if they have access explicitly granted - public boolean subjectAccessIsRestricted(Object testSubject) - { - return (!this.isHostFactionAllowed() && this.doesHostFactionMatch(testSubject)); + if (this.getPlayerIds().contains(uplayer.getId())) return true; + + String factionId = uplayer.getFactionId(); + if (this.getFactionIds().contains(factionId)) return true; + + if (this.getHostFactionId().equals(factionId) && !this.isHostFactionAllowed()) return false; + + return null; } } \ No newline at end of file diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java b/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java index 8d5a03a8..969e7a51 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java @@ -39,7 +39,7 @@ public class CmdFactionsClaim extends FCommand if (forFaction == null) return; // FPerm - if (forFaction.isNormal() && !FPerm.TERRITORY.has(sender, forFaction, true)) return; + if (forFaction.isNormal() && !FPerm.TERRITORY.has(usender, forFaction, true)) return; // Validate if (radius < 1) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java index fcd2a914..fd812172 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java @@ -36,7 +36,7 @@ public class CmdFactionsDisband extends FCommand if (faction == null) return; // FPerm - if ( ! FPerm.DISBAND.has(sender, faction, true)) return; + if ( ! FPerm.DISBAND.has(usender, faction, true)) return; // Verify if (faction.getFlag(FFlag.PERMANENT)) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java b/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java index dc078e10..395c8828 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java @@ -46,7 +46,7 @@ public class CmdFactionsInvite extends FCommand } // FPerm - if ( ! FPerm.INVITE.has(sender, usenderFaction, true)) return; + if ( ! FPerm.INVITE.has(usender, usenderFaction, true)) return; // Event FactionsEventInvitedChange event = new FactionsEventInvitedChange(sender, uplayer, usenderFaction, newInvited); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java index 2618e3e2..e07378e3 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java @@ -57,7 +57,7 @@ public class CmdFactionsKick extends FCommand // FPerm Faction uplayerFaction = uplayer.getFaction(); - if (!FPerm.KICK.has(sender, uplayerFaction, true)) return; + if (!FPerm.KICK.has(usender, uplayerFaction, true)) return; // Event FactionsEventMembershipChange event = new FactionsEventMembershipChange(sender, uplayer, FactionColls.get().get(uplayer).getNone(), MembershipChangeReason.KICK); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java b/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java index 939dd068..c279fc03 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java @@ -57,7 +57,7 @@ public class CmdFactionsPerm extends FCommand } // Do the sender have the right to change perms for this faction? - if ( ! FPerm.PERMS.has(sender, faction, true)) return; + if ( ! FPerm.PERMS.has(usender, faction, true)) return; Rel rel = this.arg(2, ARRel.get()); if (rel == null) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java index 6929d91e..c22504e7 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -42,7 +42,7 @@ public class CmdFactionsSethome extends FCommand } // FPerm - if ( ! FPerm.SETHOME.has(sender, faction, true)) return; + if ( ! FPerm.SETHOME.has(usender, faction, true)) return; // Verify if (!usender.isUsingAdminMode() && !faction.isValidHome(newHome)) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index 51e29114..7059336f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -30,7 +30,7 @@ public class CmdFactionsUnclaim extends FCommand Faction newFaction = FactionColls.get().get(me).getNone(); // FPerm - if (!FPerm.TERRITORY.has(sender, usenderFaction, true)) return; + if (!FPerm.TERRITORY.has(usender, usenderFaction, true)) return; // Apply if (usender.tryClaim(newFaction, chunk, true, true)) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java index 6c091a8c..cea0399f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java @@ -38,7 +38,7 @@ public class CmdFactionsUnclaimall extends FCommand Faction newFaction = FactionColls.get().get(faction).getNone(); // FPerm - if (!FPerm.TERRITORY.has(sender, faction, true)) return; + if (!FPerm.TERRITORY.has(usender, faction, true)) return; // Apply BoardColl boardColl = BoardColls.get().get(faction); diff --git a/src/com/massivecraft/factions/integration/Econ.java b/src/com/massivecraft/factions/integration/Econ.java index 15b2e51c..e79fd5f7 100644 --- a/src/com/massivecraft/factions/integration/Econ.java +++ b/src/com/massivecraft/factions/integration/Econ.java @@ -89,7 +89,7 @@ public class Econ if (i == fI && fI == fYou) return true; // Factions can be controlled by those that have permissions - if (you instanceof Faction && FPerm.WITHDRAW.has(i, fYou, false)) return true; + if (you instanceof Faction && FPerm.WITHDRAW.has(fI, fYou)) return true; // Otherwise you may not! ;,,; i.msg("%s lacks permission to control %s's money.", i.describeTo(i, true), you.describeTo(i)); diff --git a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java index 6ffab3be..46c5f846 100644 --- a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -138,17 +138,26 @@ public class FactionsListenerMain implements Listener player.sendMessage(msg); } - // show access info message if needed + // Show access level message if it changed. + TerritoryAccess accessFrom = BoardColls.get().getTerritoryAccessAt(chunkFrom); + Boolean hasTerritoryAccessFrom = accessFrom.hasTerritoryAccess(uplayer); + TerritoryAccess accessTo = BoardColls.get().getTerritoryAccessAt(chunkTo); - if (!accessTo.isDefault()) + Boolean hasTerritoryAccessTo = accessTo.hasTerritoryAccess(uplayer); + + if (!MUtil.equals(hasTerritoryAccessFrom, hasTerritoryAccessTo)) { - if (accessTo.subjectHasAccess(uplayer)) + if (hasTerritoryAccessTo == null) { - uplayer.msg("You have access to this area."); + uplayer.msg("You have standard access to this area."); } - else if (accessTo.subjectAccessIsRestricted(uplayer)) + else if (hasTerritoryAccessTo) { - uplayer.msg("This area has restricted access."); + uplayer.msg("You have elevated access to this area."); + } + else + { + uplayer.msg("You have decreased access to this area."); } } } @@ -691,33 +700,32 @@ public class FactionsListenerMain implements Listener // FLAG: BUILD // -------------------------------------------- // - public static boolean canPlayerBuildAt(Player player, PS ps, boolean justCheck) + public static boolean canPlayerBuildAt(Player player, PS ps, boolean verboose) { String name = player.getName(); if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; - UPlayer me = UPlayer.get(player); - if (me.isUsingAdminMode()) return true; + UPlayer uplayer = UPlayer.get(player); + if (uplayer.isUsingAdminMode()) return true; - Faction factionHere = BoardColls.get().getFactionAt(ps); - - if ( ! FPerm.BUILD.has(me, ps) && FPerm.PAINBUILD.has(me, ps)) + if (!FPerm.BUILD.has(uplayer, ps, false) && FPerm.PAINBUILD.has(uplayer, ps, false)) { - if (!justCheck) + if (verboose) { - me.msg("It is painful to build in the territory of %s.", factionHere.describeTo(me)); + Faction hostFaction = BoardColls.get().getFactionAt(ps); + uplayer.msg("It is painful to build in the territory of %s.", hostFaction.describeTo(uplayer)); player.damage(UConf.get(player).actionDeniedPainAmount); } return true; } - return FPerm.BUILD.has(me, ps, true); + return FPerm.BUILD.has(uplayer, ps, verboose); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockBuild(HangingPlaceEvent event) { - if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getEntity()), false)) return; + if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getEntity()), true)) return; event.setCancelled(true); } @@ -731,7 +739,7 @@ public class FactionsListenerMain implements Listener Entity breaker = entityEvent.getRemover(); if (! (breaker instanceof Player)) return; - if ( ! canPlayerBuildAt((Player)breaker, PS.valueOf(event.getEntity()), false)) + if ( ! canPlayerBuildAt((Player)breaker, PS.valueOf(event.getEntity()), true)) { event.setCancelled(true); } @@ -742,7 +750,7 @@ public class FactionsListenerMain implements Listener { if (!event.canBuild()) return; - if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), false)) return; + if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) return; event.setBuild(false); event.setCancelled(true); @@ -751,7 +759,7 @@ public class FactionsListenerMain implements Listener @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockBuild(BlockBreakEvent event) { - if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), false)) return; + if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) return; event.setCancelled(true); } @@ -761,7 +769,7 @@ public class FactionsListenerMain implements Listener { if (!event.getInstaBreak()) return; - if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), false)) return; + if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) return; event.setCancelled(true); } @@ -781,7 +789,7 @@ public class FactionsListenerMain implements Listener if (targetFaction == pistonFaction) return; // if potentially pushing into air/water/lava in another territory, we need to check it out - if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && ! FPerm.BUILD.has(pistonFaction, PS.valueOf(targetBlock))) + if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && ! FPerm.BUILD.has(pistonFaction, targetFaction)) { event.setCancelled(true); } @@ -811,7 +819,7 @@ public class FactionsListenerMain implements Listener Faction targetFaction = BoardColls.get().getFactionAt(retractPs); if (targetFaction == pistonFaction) return; - if (!FPerm.BUILD.has(pistonFaction, retractPs)) + if (!FPerm.BUILD.has(pistonFaction, targetFaction)) { event.setCancelled(true); }