Readd the powerboost for players and the proper maximum power per faction calculation.

This commit is contained in:
Olof Larsson
2013-04-25 07:53:21 +02:00
parent 8382d39409
commit 8070cc5579
4 changed files with 94 additions and 18 deletions

View File

@@ -2,7 +2,9 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.mcore.cmd.arg.ARDouble;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@@ -13,8 +15,9 @@ public class CmdFactionsPowerBoost extends FCommand
{
this.addAliases("powerboost");
this.addRequiredArg("faction");
this.addRequiredArg("amount");
this.addRequiredArg("p|f|player|faction");
this.addRequiredArg("name");
this.addRequiredArg("#");
this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node));
}
@@ -22,17 +25,42 @@ public class CmdFactionsPowerBoost extends FCommand
@Override
public void perform()
{
Faction faction = this.arg(0, ARFaction.get(usender));
if (faction == null) return;
String type = this.arg(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 amount = this.arg(1, ARDouble.get());
if (amount == null) return;
Double targetPower = this.arg(2, ARDouble.get());
if (targetPower == null) return;
faction.setPowerBoost(amount);
msg("<i>"+faction.getName()+" now has a power bonus/penalty of "+amount+" to min and max power levels.");
// TODO: Inconsistent. Why is there no boolean to toggle this logging of?
Factions.get().log(usender.getName()+" has set the power bonus/penalty for "+faction.getName()+" to "+amount+".");
String target;
if (doPlayer)
{
UPlayer targetPlayer = this.arg(1, ARUPlayer.getStartAny(sender));
if (targetPlayer == null) return;
targetPlayer.setPowerBoost(targetPower);
target = "Player \""+targetPlayer.getName()+"\"";
}
else
{
Faction targetFaction = this.arg(1, ARFaction.get(sender));
if (targetFaction == null) return;
targetFaction.setPowerBoost(targetPower);
target = "Faction \""+targetFaction.getName()+"\"";
}
msg("<i>"+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels.");
Factions.get().log(usender.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+".");
}
}