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

View File

@ -2,25 +2,27 @@ 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
*/
public CmdCheckpoint() {
public CmdCheckpoint()
{
super();
this.aliases.addAll(Aliases.checkpoint);
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
@ -29,18 +31,42 @@ public class CmdCheckpoint extends FCommand {
context.msg(TL.COMMAND_CHECKPOINT_DISABLED);
return;
}
if (context.args.size() == 1) {
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() {
public TL getUsageTranslation()
{
return TL.COMMAND_CHECKPOINT_DESCRIPTION;
}
}