69 lines
2.0 KiB
Java
69 lines
2.0 KiB
Java
|
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");
|
||
|
|
||
|
this.permission = Permission.FLIGHT.node;
|
||
|
this.senderMustBeMember = true;
|
||
|
this.senderMustBeModerator = false;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void perform() {
|
||
|
if (!P.p.getConfig().getBoolean("enable-faction-flight", false)) {
|
||
|
fme.msg(TL.COMMAND_FLY_DISABLED);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
}
|