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-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 {
|
|
|
|
|
|
|
|
public CmdPointsAdd() {
|
|
|
|
super();
|
|
|
|
this.aliases.add("add");
|
|
|
|
|
2019-08-07 01:39:20 +02:00
|
|
|
this.requiredArgs.add("faction/player");
|
2019-07-01 05:22:28 +02:00
|
|
|
this.requiredArgs.add("# of points");
|
|
|
|
|
|
|
|
|
|
|
|
this.errorOnToManyArgs = false;
|
|
|
|
//this.optionalArgs
|
|
|
|
|
|
|
|
this.permission = Permission.ADDPOINTS.node;
|
|
|
|
|
|
|
|
this.disableOnLock = true;
|
|
|
|
|
|
|
|
senderMustBePlayer = false;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeColeader = false;
|
|
|
|
senderMustBeAdmin = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
|
|
|
Faction faction = Factions.getInstance().getByTag(args.get(0));
|
|
|
|
|
2019-08-07 18:05:20 +02:00
|
|
|
if (faction == null) {
|
|
|
|
FPlayer fPlayer = this.argAsFPlayer(0);
|
|
|
|
if (fPlayer != null) {
|
|
|
|
faction = fPlayer.getFaction();
|
|
|
|
}
|
2019-08-07 01:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (faction == null || faction.isWilderness()) {
|
2019-08-07 20:35:19 +02:00
|
|
|
msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0)));
|
2019-07-01 06:30:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
if (argAsInt(1) <= 0) {
|
2019-08-07 20:35:19 +02:00
|
|
|
msg(TL.COMMAND_POINTS_INSUFFICIENT);
|
2019-07-01 06:30:23 +02:00
|
|
|
return;
|
2019-07-01 05:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
faction.setPoints(faction.getPoints() + argAsInt(1));
|
2019-08-07 20:35:19 +02:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
msg(TL.COMMAND_POINTS_SUCCESSFUL, argAsInt(1), faction.getTag(), faction.getPoints());
|
2019-07-01 05:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_ADDPOINTS_DESCRIPTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|