Saber-Factions/src/main/java/com/massivecraft/factions/cmd/points/CmdPointsAdd.java

66 lines
1.7 KiB
Java
Raw Normal View History

2019-07-02 03:26:13 +02:00
package com.massivecraft.factions.cmd.points;
2019-07-01 05:22:28 +02:00
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
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");
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));
FPlayer fPlayer = this.argAsFPlayer(0);
if (fPlayer != null) {
faction = fPlayer.getFaction();
}
if (faction == null || faction.isWilderness()) {
2019-07-01 05:22:28 +02:00
fme.msg(TL.COMMAND_POINTS_FAILURE.toString().replace("{faction}", args.get(0)));
2019-07-01 06:30:23 +02:00
return;
}
if(argAsInt(1) <= 0){
fme.msg(TL.COMMAND_POINTS_INSUFFICIENT);
return;
2019-07-01 05:22:28 +02:00
}
faction.setPoints(faction.getPoints() + argAsInt(1));
fme.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;
}
}