2012-01-28 18:56:51 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
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;
|
2013-04-22 17:59:51 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARUPlayer;
|
2013-04-16 11:27:03 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
2013-04-22 17:59:51 +02:00
|
|
|
import com.massivecraft.factions.entity.UPlayer;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2013-04-16 11:27:03 +02:00
|
|
|
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
2013-04-16 10:11:59 +02:00
|
|
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
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
|
|
|
{
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addAliases("powerboost");
|
2012-01-28 18:56:51 +01:00
|
|
|
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addRequiredArg("p|f|player|faction");
|
|
|
|
this.addRequiredArg("name");
|
|
|
|
this.addRequiredArg("#");
|
2012-01-28 18:56:51 +01:00
|
|
|
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node));
|
2012-01-28 18:56:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform()
|
|
|
|
{
|
2013-04-16 11:05:49 +02:00
|
|
|
String type = this.arg(0).toLowerCase();
|
2012-01-28 18:56:51 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-04-16 11:27:03 +02:00
|
|
|
Double targetPower = this.arg(2, ARDouble.get());
|
|
|
|
if (targetPower == null) return;
|
2012-01-28 18:56:51 +01:00
|
|
|
|
|
|
|
String target;
|
|
|
|
|
|
|
|
if (doPlayer)
|
|
|
|
{
|
2013-04-22 17:59:51 +02:00
|
|
|
UPlayer targetPlayer = this.arg(1, ARUPlayer.getStartAny(sender));
|
2012-01-28 18:56:51 +01:00
|
|
|
if (targetPlayer == null) return;
|
2013-04-16 11:27:03 +02:00
|
|
|
|
2012-01-28 18:56:51 +01:00
|
|
|
targetPlayer.setPowerBoost(targetPower);
|
|
|
|
target = "Player \""+targetPlayer.getName()+"\"";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-22 13:03:21 +02:00
|
|
|
Faction targetFaction = this.arg(1, ARFaction.get(sender));
|
2012-01-28 18:56:51 +01:00
|
|
|
if (targetFaction == null) return;
|
2013-04-16 11:27:03 +02:00
|
|
|
|
2012-01-28 18:56:51 +01:00
|
|
|
targetFaction.setPowerBoost(targetPower);
|
|
|
|
target = "Faction \""+targetFaction.getTag()+"\"";
|
|
|
|
}
|
|
|
|
|
|
|
|
msg("<i>"+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels.");
|
2013-04-16 11:27:03 +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
|
|
|
}
|
|
|
|
}
|