Implement /f fly (#1023)

This commit is contained in:
Dariasc
2018-03-04 19:13:32 -03:00
committed by Trent Hensler
parent aacee63255
commit a90299d32e
12 changed files with 162 additions and 4 deletions

View File

@@ -0,0 +1,68 @@
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;
}
}

View File

@@ -20,6 +20,7 @@ public class FCmdRoot extends FCommand {
public CmdDeinvite cmdDeinvite = new CmdDeinvite();
public CmdDescription cmdDescription = new CmdDescription();
public CmdDisband cmdDisband = new CmdDisband();
public CmdFly cmdFly = new CmdFly();
public CmdHelp cmdHelp = new CmdHelp();
public CmdHome cmdHome = new CmdHome();
public CmdInvite cmdInvite = new CmdInvite();
@@ -114,6 +115,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdDeinvite);
this.addSubCommand(this.cmdDescription);
this.addSubCommand(this.cmdDisband);
this.addSubCommand(this.cmdFly);
this.addSubCommand(this.cmdHelp);
this.addSubCommand(this.cmdHome);
this.addSubCommand(this.cmdInvite);