Implement /f fly (#1023)
This commit is contained in:
68
src/main/java/com/massivecraft/factions/cmd/CmdFly.java
Normal file
68
src/main/java/com/massivecraft/factions/cmd/CmdFly.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user