2014-11-14 20:27:23 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2014-11-14 20:27:23 +01:00
|
|
|
|
2018-02-03 21:50:12 +01:00
|
|
|
public class CmdModifyPower extends FCommand {
|
2014-11-14 20:27:23 +01:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdModifyPower() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.aliases.add("pm");
|
|
|
|
this.aliases.add("mp");
|
|
|
|
this.aliases.add("modifypower");
|
|
|
|
this.aliases.add("modpower");
|
|
|
|
|
|
|
|
this.requiredArgs.add("name");
|
|
|
|
this.requiredArgs.add("power");
|
|
|
|
|
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.MODIFY_POWER)
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
// /f modify <name> #
|
|
|
|
FPlayer player = context.argAsBestFPlayerMatch(0);
|
|
|
|
Double number = context.argAsDouble(1); // returns null if not a Double.
|
|
|
|
|
|
|
|
if (player == null || number == null) {
|
|
|
|
context.sender.sendMessage(getHelpShort());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
player.alterPower(number);
|
|
|
|
int newPower = player.getPowerRounded(); // int so we don't have super long doubles.
|
|
|
|
context.msg(TL.COMMAND_MODIFYPOWER_ADDED, number, player.getName(), newPower);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_MODIFYPOWER_DESCRIPTION;
|
|
|
|
}
|
2014-11-14 20:27:23 +01:00
|
|
|
}
|