2018-03-27 01:42:26 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.*;
|
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
import com.massivecraft.factions.util.WarmUpUtil;
|
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
|
|
|
|
public class CmdCheckpoint extends FCommand {
|
2019-03-03 04:51:21 +01:00
|
|
|
public CmdCheckpoint() {
|
|
|
|
super();
|
|
|
|
this.aliases.add("checkp");
|
|
|
|
this.aliases.add("checkpoint");
|
|
|
|
this.aliases.add("cpoint");
|
2018-03-27 01:42:26 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
this.optionalArgs.put("set", "");
|
2018-03-27 01:42:26 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
this.permission = Permission.CHECKPOINT.node;
|
|
|
|
this.disableOnLock = false;
|
2018-03-27 01:42:26 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = true;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeColeader = false;
|
|
|
|
senderMustBeAdmin = false;
|
|
|
|
}
|
2018-03-27 01:42:26 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
@Override
|
|
|
|
public void perform() {
|
2019-08-02 23:01:33 +02:00
|
|
|
if (!P.p.getConfig().getBoolean("checkpoints.Enabled")) {
|
2019-03-03 04:51:21 +01:00
|
|
|
fme.msg(TL.COMMAND_CHECKPOINT_DISABLED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (args.size() == 1) {
|
|
|
|
FLocation myLocation = new FLocation(fme.getPlayer().getLocation());
|
|
|
|
Faction myLocFaction = Board.getInstance().getFactionAt(myLocation);
|
|
|
|
if (myLocFaction == Factions.getInstance().getWilderness() || myLocFaction == fme.getFaction()) {
|
|
|
|
fme.getFaction().setCheckpoint(fme.getPlayer().getLocation());
|
|
|
|
fme.msg(TL.COMMAND_CHECKPOINT_SET);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
fme.msg(TL.COMMAND_CHECKPOINT_INVALIDLOCATION);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fme.getFaction().getCheckpoint() == null) {
|
|
|
|
fme.msg(TL.COMMAND_CHECKPOINT_NOT_SET);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FLocation checkLocation = new FLocation(fme.getFaction().getCheckpoint());
|
|
|
|
Faction checkfaction = Board.getInstance().getFactionAt(checkLocation);
|
2018-03-27 01:42:26 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(fme.getFaction().getId())) {
|
|
|
|
fme.msg(TL.COMMAND_CHECKPOINT_GO);
|
2019-04-16 15:02:31 +02:00
|
|
|
this.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", () -> fme.getPlayer().teleport(fme.getFaction().getCheckpoint()), this.p.getConfig().getLong("warmups.f-checkpoint", 0));
|
2019-03-03 04:51:21 +01:00
|
|
|
} else {
|
|
|
|
fme.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
|
|
|
|
}
|
2018-03-27 15:17:55 +02:00
|
|
|
|
2018-03-27 01:42:26 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
}
|
2018-03-27 01:42:26 +02:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_CHECKPOINT_DESCRIPTION;
|
|
|
|
}
|
2018-03-27 01:42:26 +02:00
|
|
|
}
|