From ec1501bf4fc579d2773236f29ea029e82734695c Mon Sep 17 00:00:00 2001 From: Juniormunk Date: Thu, 21 May 2020 02:51:41 -0400 Subject: [PATCH] Fix Bug #125 --- .../factions/cmd/CmdCheckpoint.java | 83 ++++++++++++------- 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCheckpoint.java b/src/main/java/com/massivecraft/factions/cmd/CmdCheckpoint.java index b70ebb92..7b453a49 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdCheckpoint.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdCheckpoint.java @@ -2,45 +2,71 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.*; import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.struct.Role; 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; -public class CmdCheckpoint extends FCommand { +public class CmdCheckpoint extends FCommand +{ - /** - * @author Illyria Team - */ + /** + * @author Illyria Team + */ - public CmdCheckpoint() { - super(); - this.aliases.addAll(Aliases.checkpoint); + public CmdCheckpoint() + { + super(); + this.aliases.addAll(Aliases.checkpoint); - this.optionalArgs.put("set", ""); + this.optionalArgs.put("set", ""); - this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT) - .playerOnly() - .memberOnly() - .build(); - } + this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT).playerOnly().memberOnly().build(); + } - @Override + @Override public void perform(CommandContext context) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("checkpoints.Enabled")) { context.msg(TL.COMMAND_CHECKPOINT_DISABLED); return; } - if (context.args.size() == 1) { - FLocation myLocation = new FLocation(context.player.getLocation()); - Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); - if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) { - context.faction.setCheckpoint(context.player.getLocation()); - context.msg(TL.COMMAND_CHECKPOINT_SET); - return; - } else { - context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); + if (context.args.size() == 1 && context.args.get(0).equalsIgnoreCase("set")) { + if (context.fPlayer.getRole() == Role.LEADER) + { + FLocation myLocation = new FLocation(context.player.getLocation()); + Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); + if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) { + context.faction.setCheckpoint(context.player.getLocation()); + context.msg(TL.COMMAND_CHECKPOINT_SET); + return; + } + } else { + context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); + return; + } + + PermissableAction action = PermissableAction.SETWARP; + Access access = context.faction.getAccess(context.fPlayer, action); + if (access == Access.DENY) { + context.msg(TL.GENERIC_FPERM_NOPERMISSION, action.getName()); return; } + else + { + FLocation myLocation = new FLocation(context.player.getLocation()); + Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); + if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) { + context.faction.setCheckpoint(context.player.getLocation()); + context.msg(TL.COMMAND_CHECKPOINT_SET); + return; + }else { + context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); + return; + } + } } + if (context.faction.getCheckpoint() == null) { context.msg(TL.COMMAND_CHECKPOINT_NOT_SET); return; @@ -57,12 +83,11 @@ public class CmdCheckpoint extends FCommand { } else { context.msg(TL.COMMAND_CHECKPOINT_CLAIMED); } - - } - @Override - public TL getUsageTranslation() { - return TL.COMMAND_CHECKPOINT_DESCRIPTION; - } + @Override + public TL getUsageTranslation() + { + return TL.COMMAND_CHECKPOINT_DESCRIPTION; + } }