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

69 lines
2.4 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
2014-04-04 20:55:21 +02:00
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
2014-04-04 20:55:21 +02:00
public class CmdPowerBoost extends FCommand {
2014-04-04 20:55:21 +02:00
public CmdPowerBoost() {
2014-07-01 22:10:18 +02:00
super();
this.aliases.add("powerboost");
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +02:00
this.requiredArgs.add("p|f|player|faction");
this.requiredArgs.add("name");
this.requiredArgs.add("#");
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +02:00
this.permission = Permission.POWERBOOST.node;
this.disableOnLock = true;
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +02:00
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
2014-04-04 20:55:21 +02:00
senderMustBeAdmin = false;
}
@Override
public void perform() {
2014-07-01 22:10:18 +02:00
String type = this.argAsString(0).toLowerCase();
boolean doPlayer = true;
2014-04-04 20:55:21 +02:00
if (type.equals("f") || type.equals("faction")) {
doPlayer = false;
2014-07-01 21:52:40 +02:00
} else if (!type.equals("p") && !type.equals("player")) {
2014-04-04 20:55:21 +02:00
msg("<b>You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction.");
2014-07-01 22:10:18 +02:00
msg("<b>ex. /f powerboost p SomePlayer 0.5 -or- /f powerboost f SomeFaction -5");
return;
2014-04-04 20:55:21 +02:00
}
2014-07-01 22:10:18 +02:00
Double targetPower = this.argAsDouble(2);
if (targetPower == null) {
msg("<b>You must specify a valid numeric value for the power bonus/penalty amount.");
return;
2014-04-04 20:55:21 +02:00
}
2014-04-04 20:55:21 +02:00
String target;
2014-04-04 20:55:21 +02:00
if (doPlayer) {
2014-07-01 22:10:18 +02:00
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1);
if (targetPlayer == null) {
return;
}
targetPlayer.setPowerBoost(targetPower);
target = "Player \"" + targetPlayer.getName() + "\"";
2014-07-01 21:52:40 +02:00
} else {
2014-07-01 22:10:18 +02:00
Faction targetFaction = this.argAsFaction(1);
if (targetFaction == null) {
return;
}
targetFaction.setPowerBoost(targetPower);
target = "Faction \"" + targetFaction.getTag() + "\"";
2014-04-04 20:55:21 +02:00
}
2014-04-04 20:55:21 +02:00
msg("<i>" + target + " now has a power bonus/penalty of " + targetPower + " to min and max power levels.");
2014-07-01 21:49:42 +02:00
if (!senderIsConsole) {
2014-04-04 20:55:21 +02:00
P.p.log(fme.getName() + " has set the power bonus/penalty for " + target + " to " + targetPower + ".");
2014-07-01 21:49:42 +02:00
}
2014-04-04 20:55:21 +02:00
}
}