Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdFly.java

64 lines
1.9 KiB
Java
Raw Normal View History

2018-03-04 23:13:32 +01:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.WarmUpUtil;
import com.massivecraft.factions.zcore.util.TL;
public class CmdFly extends FCommand {
public CmdFly() {
super();
this.aliases.add("fly");
this.optionalArgs.put("on/off", "flip");
2018-03-04 23:16:17 +01:00
this.permission = Permission.FLY.node;
2018-03-04 23:13:32 +01:00
this.senderMustBeMember = true;
this.senderMustBeModerator = false;
}
@Override
public void perform() {
if (args.size() == 0) {
if (!fme.canFlyAtLocation() && !fme.isFlying()) {
Faction factionAtLocation = Board.getInstance().getFactionAt(fme.getLastStoodAt());
fme.msg(TL.COMMAND_FLY_NO_ACCESS, factionAtLocation.getTag(fme));
return;
}
toggleFlight(!fme.isFlying());
} else if (args.size() == 1) {
if (!fme.canFlyAtLocation() && argAsBool(0)) {
Faction factionAtLocation = Board.getInstance().getFactionAt(fme.getLastStoodAt());
fme.msg(TL.COMMAND_FLY_NO_ACCESS, factionAtLocation.getTag(fme));
return;
}
toggleFlight(argAsBool(0));
}
}
private void toggleFlight(final boolean toggle) {
if (!toggle) {
fme.setFlying(false);
return;
}
this.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", new Runnable() {
@Override
public void run() {
fme.setFlying(true);
}
}, this.p.getConfig().getLong("warmups.f-fly", 0));
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_FLY_DESCRIPTION;
}
}