From 1b088ccd54cf79e7783f67d1cd293b35d65465ab Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Sat, 3 Feb 2018 13:04:21 -0800 Subject: [PATCH] Set warp and f warp f perms --- .../com/massivecraft/factions/cmd/CmdFWarp.java | 12 ++++++++++++ .../massivecraft/factions/cmd/CmdSetFWarp.java | 17 ++++++++++++++++- .../zcore/fperms/PermissableAction.java | 5 ++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java index 6d944b06..5b698274 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java @@ -4,8 +4,11 @@ import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.LazyLocation; import com.massivecraft.factions.util.WarmUpUtil; +import com.massivecraft.factions.zcore.fperms.Access; +import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; import mkremins.fanciful.FancyMessage; import org.bukkit.Bukkit; @@ -32,6 +35,15 @@ public class CmdFWarp extends FCommand { @Override public void perform() { //TODO: check if in combat. + + // Check for access first. + Access access = myFaction.getAccess(fme, PermissableAction.WARP); + + if (access == Access.DENY) { + fme.msg(TL.GENERIC_NOPERMISSION, "warp"); + return; + } + if (args.size() == 0) { FancyMessage msg = new FancyMessage(TL.COMMAND_FWARP_WARPS.toString()).color(ChatColor.GOLD); Map warps = myFaction.getWarps(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java index a1973341..9f066019 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java @@ -4,20 +4,27 @@ import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.LazyLocation; +import com.massivecraft.factions.zcore.fperms.Access; +import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; public class CmdSetFWarp extends FCommand { public CmdSetFWarp() { super(); + this.aliases.add("setwarp"); this.aliases.add("sw"); + this.requiredArgs.add("warp name"); this.optionalArgs.put("password", "password"); + this.senderMustBeMember = true; - this.senderMustBeModerator = true; + this.senderMustBeModerator = false; this.senderMustBePlayer = true; + this.permission = Permission.SETWARP.node; } @@ -28,6 +35,14 @@ public class CmdSetFWarp extends FCommand { return; } + Access access = myFaction.getAccess(fme, PermissableAction.SETWARP); + // This statement allows us to check if they've specifically denied it, or default to + // the old setting of allowing moderators to set warps. + if (access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) { + fme.msg(TL.GENERIC_NOPERMISSION, "set warp"); + return; + } + int maxWarps = P.p.getConfig().getInt("max-warps", 5); if (maxWarps <= myFaction.getWarps().size()) { fme.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps); diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java index 9818a654..dfb3e2fc 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java @@ -18,7 +18,10 @@ public enum PermissableAction { ACCESS("access"), DISBAND("disband"), PROMOTE("promote"), - PERMS("perms"); + PERMS("perms"), + SETWARP("setwarp"), + WARP("warp"), + ; private String name;