This commit is contained in:
Juniormunk 2020-05-21 02:51:41 -04:00
parent 8ad2fdf848
commit ec1501bf4f

View File

@ -2,45 +2,71 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.WarmUpUtil; 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 com.massivecraft.factions.zcore.util.TL;
public class CmdCheckpoint extends FCommand { public class CmdCheckpoint extends FCommand
{
/** /**
* @author Illyria Team * @author Illyria Team
*/ */
public CmdCheckpoint() { public CmdCheckpoint()
super(); {
this.aliases.addAll(Aliases.checkpoint); super();
this.aliases.addAll(Aliases.checkpoint);
this.optionalArgs.put("set", ""); this.optionalArgs.put("set", "");
this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT) this.requirements = new CommandRequirements.Builder(Permission.CHECKPOINT).playerOnly().memberOnly().build();
.playerOnly() }
.memberOnly()
.build();
}
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("checkpoints.Enabled")) { if (!FactionsPlugin.getInstance().getConfig().getBoolean("checkpoints.Enabled")) {
context.msg(TL.COMMAND_CHECKPOINT_DISABLED); context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
return; return;
} }
if (context.args.size() == 1) { if (context.args.size() == 1 && context.args.get(0).equalsIgnoreCase("set")) {
FLocation myLocation = new FLocation(context.player.getLocation()); if (context.fPlayer.getRole() == Role.LEADER)
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation); {
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) { FLocation myLocation = new FLocation(context.player.getLocation());
context.faction.setCheckpoint(context.player.getLocation()); Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
context.msg(TL.COMMAND_CHECKPOINT_SET); if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == context.faction) {
return; context.faction.setCheckpoint(context.player.getLocation());
} else { context.msg(TL.COMMAND_CHECKPOINT_SET);
context.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION); 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; 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) { if (context.faction.getCheckpoint() == null) {
context.msg(TL.COMMAND_CHECKPOINT_NOT_SET); context.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
return; return;
@ -57,12 +83,11 @@ public class CmdCheckpoint extends FCommand {
} else { } else {
context.msg(TL.COMMAND_CHECKPOINT_CLAIMED); context.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation()
return TL.COMMAND_CHECKPOINT_DESCRIPTION; {
} return TL.COMMAND_CHECKPOINT_DESCRIPTION;
}
} }