Add command to modify a player's power specified in #133.

use /f modpower name number
This commit is contained in:
drtshock 2014-11-14 13:27:23 -06:00
parent 104f90c1db
commit bad874495b
4 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,43 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
public class CmdModifyPower extends FCommand {
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.permission = Permission.MODIFY_POWER.node; // admin only perm.
// Let's not require anything and let console modify this as well.
this.senderMustBeAdmin = false;
this.senderMustBePlayer = false;
this.senderMustBeMember = false;
this.senderMustBeModerator = false;
}
@Override
public void perform() {
// /f modify <name> #
FPlayer player = argAsBestFPlayerMatch(0);
Double number = argAsDouble(1); // returns null if not a Double.
if (player == null || number == null) {
sender.sendMessage(getHelpShort());
return;
}
player.alterPower(number);
int newPower = player.getPowerRounded(); // int so we don't have super long doubles.
msg("<i>Added <a>%d <i>power to <a>%s. <i>New total rounded power: <a>%d", number, player.getName(), newPower);
}
}

View File

@ -60,6 +60,7 @@ public class FCmdRoot extends FCommand {
public CmdFWarp cmdFWarp = new CmdFWarp();
public CmdSetFWarp cmdSetFWarp = new CmdSetFWarp();
public CmdDelFWarp cmdDelFWarp = new CmdDelFWarp();
public CmdModifyPower cmdModifyPower = new CmdModifyPower();
public FCmdRoot() {
super();
@ -136,6 +137,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdFWarp);
this.addSubCommand(this.cmdSetFWarp);
this.addSubCommand(this.cmdDelFWarp);
this.addSubCommand(this.cmdModifyPower);
}
@Override

View File

@ -36,6 +36,7 @@ public enum Permission {
MAP("map"),
MOD("mod"),
MOD_ANY("mod.any"),
MODIFY_POWER("modifypower"),
MONEY_BALANCE("money.balance"),
MONEY_BALANCE_ANY("money.balance.any"),
MONEY_DEPOSIT("money.deposit"),

View File

@ -16,6 +16,7 @@ permissions:
factions.lock: true
factions.reload: true
factions.save: true
factions.modifypower: true
factions.*:
description: This is just an alias for factions.kit.admin
children:
@ -237,4 +238,6 @@ permissions:
factions.setwarp:
description: set a warp for your faction
factions.warp:
description: access your faction warps
description: access your faction warps
factions.modifypower:
description: modify other player's power