Factions3/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java

88 lines
2.8 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
2013-04-09 13:00:09 +02:00
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.type.TypeFaction;
import com.massivecraft.factions.cmd.type.TypeMPlayer;
import com.massivecraft.factions.entity.MPlayer;
2013-04-22 09:37:53 +02:00
import com.massivecraft.factions.entity.Faction;
2015-02-12 12:00:55 +01:00
import com.massivecraft.massivecore.MassiveException;
2015-11-06 02:10:29 +01:00
import com.massivecraft.massivecore.command.Parameter;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.primitive.TypeDouble;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
2014-09-18 13:41:20 +02:00
public class CmdFactionsPowerBoost extends FactionsCommand
{
2015-05-06 17:04:35 +02:00
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private Parameter<MPlayer> parameterMplayer = new Parameter<MPlayer>(TypeMPlayer.get(), "name");
private Parameter<Faction> parameterFaction = new Parameter<Faction>(TypeFaction.get(), "name");
2015-05-06 17:04:35 +02:00
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2013-04-10 13:12:22 +02:00
public CmdFactionsPowerBoost()
{
2013-11-11 09:31:04 +01:00
// Aliases
2013-04-16 10:11:59 +02:00
this.addAliases("powerboost");
2013-11-11 09:31:04 +01:00
// Parameters
this.addParameter(TypeString.get(), "p|f|player|faction");
this.addParameter(parameterMplayer);
this.addParameter(TypeDouble.get(), "#");
2013-11-11 09:31:04 +01:00
// Requirements
2015-11-06 02:10:29 +01:00
this.addRequirements(RequirementHasPerm.get(Perm.POWERBOOST.node));
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
2015-02-12 12:00:55 +01:00
public void perform() throws MassiveException
{
2015-05-06 17:04:35 +02:00
String type = this.<String>readArg().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;
}
2015-05-06 17:04:35 +02:00
double targetPower = this.readArgAt(2);
String target;
if (doPlayer)
{
this.getParameters().set(1, parameterMplayer);
2015-05-06 17:04:35 +02:00
MPlayer targetPlayer = this.readArgAt(1);
targetPlayer.setPowerBoost(targetPower);
target = "Player \""+targetPlayer.getName()+"\"";
}
else
{
this.getParameters().set(1, parameterFaction);
2015-05-06 17:04:35 +02:00
Faction targetFaction = this.readArgAt(1);
targetFaction.setPowerBoost(targetPower);
target = "Faction \""+targetFaction.getName()+"\"";
}
msg("<i>"+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels.");
2014-09-18 13:41:20 +02:00
Factions.get().log(msender.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+".");
}
2013-11-11 09:31:04 +01:00
}