Added Warp, DamageIncrease & Reduction, and TNT F Upgrades

This commit is contained in:
Driftay
2019-09-15 07:51:12 -04:00
parent 7f988031ca
commit 82d2971b65
14 changed files with 543 additions and 239 deletions

View File

@@ -9,57 +9,42 @@ import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
public class CmdSetFWarp extends FCommand {
public CmdSetFWarp() {
super();
this.aliases.add("setwarp");
this.aliases.add("sw");
this.requiredArgs.add("warp name");
this.optionalArgs.put("password", "password");
this.requirements = new CommandRequirements.Builder(Permission.SETWARP)
.playerOnly()
.memberOnly()
.withAction(PermissableAction.SETWARP)
.build();
this.requirements = new CommandRequirements.Builder(Permission.SETWARP).playerOnly().memberOnly().withAction(PermissableAction.SETWARP).build();
}
@Override
public void perform(CommandContext context) {
if (!(context.fPlayer.getRelationToLocation() == Relation.MEMBER)) {
if (context.fPlayer.getRelationToLocation() != Relation.MEMBER) {
context.msg(TL.COMMAND_SETFWARP_NOTCLAIMED);
return;
}
String warp = context.argAsString(0);
// Checks if warp with same name already exists and ignores maxWarp check if it does.
boolean warpExists = context.faction.isWarp(warp);
int maxWarps = FactionsPlugin.getInstance().getConfig().getInt("max-warps", 5);
int maxWarps = context.faction.getWarpsLimit();
boolean tooManyWarps = maxWarps <= context.faction.getWarps().size();
if (tooManyWarps && !warpExists) {
context.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps);
return;
}
if (!transact(context.fPlayer, context)) {
if (!this.transact(context.fPlayer, context)) {
return;
}
String password = context.argAsString(1);
LazyLocation loc = new LazyLocation(context.player.getLocation());
context.faction.setWarp(warp, loc);
if (password != null) {
context.faction.setWarpPassword(warp, password);
}
context.msg(TL.COMMAND_SETFWARP_SET, warp, password != null ? password : "");
context.msg(TL.COMMAND_SETFWARP_SET, warp, (password != null) ? password : "");
}
private boolean transact(FPlayer player, CommandContext context) {
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.setwarp", 5), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString());
return !FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing() || context.payForCommand(FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.setwarp", 5.0), TL.COMMAND_SETFWARP_TOSET.toString(), TL.COMMAND_SETFWARP_FORSET.toString());
}
@Override

View File

@@ -115,7 +115,7 @@ public class CmdTnt extends FCommand {
context.msg(TL.GENERIC_ARGS_TOOFEW);
context.msg(context.args.get(0).equalsIgnoreCase("take") || context.args.get(0).equalsIgnoreCase("t") ? TL.COMMAND_TNT_TAKE_DESCRIPTION : TL.COMMAND_TNT_ADD_DESCRIPTION);
}
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + ""));
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{bankSize}", context.faction.getTntBankLimit() + ""));
}