2012-01-28 18:56:51 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Faction;
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
2013-04-09 13:00:09 +02:00
|
|
|
import com.massivecraft.factions.Factions;
|
2013-04-09 12:56:29 +02:00
|
|
|
import com.massivecraft.factions.Perm;
|
2012-01-28 18:56:51 +01:00
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public class CmdFactionsPowerBoost extends FCommand
|
2012-01-28 18:56:51 +01:00
|
|
|
{
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsPowerBoost()
|
2012-01-28 18:56:51 +01:00
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.aliases.add("powerboost");
|
|
|
|
|
|
|
|
this.requiredArgs.add("p|f|player|faction");
|
|
|
|
this.requiredArgs.add("name");
|
|
|
|
this.requiredArgs.add("#");
|
|
|
|
|
2013-04-09 12:56:29 +02:00
|
|
|
this.permission = Perm.POWERBOOST.node;
|
2012-01-28 18:56:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform()
|
|
|
|
{
|
|
|
|
String type = this.argAsString(0).toLowerCase();
|
|
|
|
boolean doPlayer = true;
|
|
|
|
if (type.equals("f") || type.equals("faction"))
|
|
|
|
{
|
|
|
|
doPlayer = false;
|
|
|
|
}
|
|
|
|
else if (!type.equals("p") && !type.equals("player"))
|
|
|
|
{
|
|
|
|
msg("<b>You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction.");
|
|
|
|
msg("<b>ex. /f powerboost p SomePlayer 0.5 -or- /f powerboost f SomeFaction -5");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Double targetPower = this.argAsDouble(2);
|
|
|
|
if (targetPower == null)
|
|
|
|
{
|
|
|
|
msg("<b>You must specify a valid numeric value for the power bonus/penalty amount.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String target;
|
|
|
|
|
|
|
|
if (doPlayer)
|
|
|
|
{
|
|
|
|
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1);
|
|
|
|
if (targetPlayer == null) return;
|
|
|
|
targetPlayer.setPowerBoost(targetPower);
|
|
|
|
target = "Player \""+targetPlayer.getName()+"\"";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Faction targetFaction = this.argAsFaction(1);
|
|
|
|
if (targetFaction == null) return;
|
|
|
|
targetFaction.setPowerBoost(targetPower);
|
|
|
|
target = "Faction \""+targetFaction.getTag()+"\"";
|
|
|
|
}
|
|
|
|
|
|
|
|
msg("<i>"+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels.");
|
|
|
|
if (!senderIsConsole)
|
2013-04-09 13:12:13 +02:00
|
|
|
Factions.get().log(fme.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+".");
|
2012-01-28 18:56:51 +01:00
|
|
|
}
|
|
|
|
}
|