From 07d8d959691daee271dab98377e26cee820fc9a1 Mon Sep 17 00:00:00 2001 From: ProSavage Date: Tue, 17 Jul 2018 09:03:01 -0500 Subject: [PATCH] Containers can now be accessed by default if undefined & the player is in the same faction as the container being accessed. --- .../massivecraft/factions/cmd/CmdClaim.java | 11 +++++++++++ .../massivecraft/factions/cmd/CmdUnclaim.java | 19 ++++++++++++++++++- .../listeners/FactionsPlayerListener.java | 4 +++- .../factions/zcore/persist/MemoryFPlayer.java | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java index 34fcf283..d70628ea 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java @@ -5,6 +5,8 @@ import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.util.SpiralTask; +import com.massivecraft.factions.zcore.fperms.Access; +import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; @@ -34,6 +36,15 @@ public class CmdClaim extends FCommand { int radius = this.argAsInt(0, 1); // Default to 1 final Faction forFaction = this.argAsFaction(1, myFaction); // Default to own + if (!fme.isAdminBypassing()) { + Access access = forFaction.getAccess(fme, PermissableAction.TERRITORY); + if (access == Access.DENY) { + fme.msg(TL.GENERIC_NOPERMISSION, "change faction territory!"); + return; + } + } + + if (radius < 1) { msg(TL.COMMAND_CLAIM_INVALIDRADIUS); return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java index 285b4d9c..c07d19b9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java @@ -6,6 +6,8 @@ import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.SpiralTask; +import com.massivecraft.factions.zcore.fperms.Access; +import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; @@ -33,6 +35,16 @@ public class CmdUnclaim extends FCommand { int radius = this.argAsInt(0, 1); // Default to 1 final Faction forFaction = this.argAsFaction(1, myFaction); // Default to own + if (!fme.isAdminBypassing()) { + Access access = forFaction.getAccess(fme, PermissableAction.TERRITORY); + if (access == Access.DENY) { + fme.msg(TL.GENERIC_NOPERMISSION, "change faction territory!"); + return; + } + } + + + if (radius < 1) { msg(TL.COMMAND_CLAIM_INVALIDRADIUS); return; @@ -117,11 +129,16 @@ public class CmdUnclaim extends FCommand { return true; } + + if (targetFaction.getAccess(fme,PermissableAction.TERRITORY) == Access.DENY) { + return false; + } + if (!assertHasFaction()) { return false; } - if (!assertMinRole(Role.MODERATOR)) { + if (targetFaction.getAccess(fme,PermissableAction.TERRITORY) != Access.ALLOW || !assertMinRole(Role.MODERATOR)) { return false; } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 7a4a3f4b..f5fe5cec 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -240,7 +240,9 @@ public class FactionsPlayerListener implements Listener { // F PERM check runs through before other checks. Access access = otherFaction.getAccess(me, action); - if (access == null || access == Access.DENY) { + if (action == PermissableAction.CONTAINER && (access == Access.UNDEFINED || access == Access.ALLOW) && me.getFaction() == otherFaction) { + return true; + } else if (access == null || access == Access.DENY) { me.msg(TL.GENERIC_NOPERMISSION, action); return false; } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index 1ad191bb..93bab19d 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -734,6 +734,8 @@ public abstract class MemoryFPlayer implements FPlayer { return true; } else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) { return true; + } else if (forFaction.getAccess(this,PermissableAction.TERRITORY) == Access.ALLOW) { + return true; } else if (myFaction != forFaction) { error = P.p.txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this)); } else if (forFaction == currentFaction) {