2019-07-02 03:26:13 +02:00
|
|
|
package com.massivecraft.factions.cmd.points;
|
2019-07-01 05:22:28 +02:00
|
|
|
|
2019-08-07 01:39:20 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
2019-07-01 05:22:28 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
|
|
|
import com.massivecraft.factions.Factions;
|
2019-09-14 21:13:01 +02:00
|
|
|
import com.massivecraft.factions.cmd.CommandContext;
|
|
|
|
import com.massivecraft.factions.cmd.CommandRequirements;
|
2019-07-02 03:26:13 +02:00
|
|
|
import com.massivecraft.factions.cmd.FCommand;
|
2019-07-01 05:22:28 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
|
|
|
|
public class CmdPointsAdd extends FCommand {
|
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public CmdPointsAdd() {
|
|
|
|
super();
|
|
|
|
this.aliases.add("add");
|
2019-07-01 05:22:28 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
this.requiredArgs.add("faction/player");
|
|
|
|
this.requiredArgs.add("# of points");
|
2019-07-01 05:22:28 +02:00
|
|
|
|
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.ADDPOINTS)
|
|
|
|
.build();
|
|
|
|
}
|
2019-07-01 05:22:28 +02:00
|
|
|
|
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
Faction faction = Factions.getInstance().getByTag(context.args.get(0));
|
2019-07-01 05:22:28 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
if (faction == null) {
|
|
|
|
FPlayer fPlayer = context.argAsFPlayer(0);
|
|
|
|
if (fPlayer != null) {
|
|
|
|
faction = fPlayer.getFaction();
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 01:39:20 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
if (faction == null || faction.isWilderness()) {
|
|
|
|
context.msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", context.args.get(0)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (context.argAsInt(1) <= 0) {
|
|
|
|
context.msg(TL.COMMAND_POINTS_INSUFFICIENT);
|
|
|
|
return;
|
|
|
|
}
|
2019-07-01 05:22:28 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
faction.setPoints(faction.getPoints() + context.argAsInt(1));
|
2019-08-07 20:35:19 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
context.msg(TL.COMMAND_POINTS_SUCCESSFUL, context.argAsInt(1), faction.getTag(), faction.getPoints());
|
|
|
|
}
|
2019-07-01 05:22:28 +02:00
|
|
|
|
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_ADDPOINTS_DESCRIPTION;
|
|
|
|
}
|
2019-07-01 05:22:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
}
|