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;
|
2015-10-21 19:35:41 +02:00
|
|
|
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
|
|
import com.massivecraft.factions.cmd.type.TypeMPlayer;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2017-02-10 16:38:36 +01:00
|
|
|
import com.massivecraft.factions.entity.MPlayer;
|
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.type.primitive.TypeDouble;
|
|
|
|
import com.massivecraft.massivecore.command.type.primitive.TypeString;
|
2012-01-28 18:56:51 +01:00
|
|
|
|
2014-09-18 13:41:20 +02:00
|
|
|
public class CmdFactionsPowerBoost extends FactionsCommand
|
2012-01-28 18:56:51 +01:00
|
|
|
{
|
2015-05-06 17:04:35 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// FIELDS
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2015-10-21 19:35:41 +02:00
|
|
|
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()
|
2012-01-28 18:56:51 +01:00
|
|
|
{
|
2015-10-21 19:35:41 +02:00
|
|
|
// Parameters
|
|
|
|
this.addParameter(TypeString.get(), "p|f|player|faction");
|
|
|
|
this.addParameter(parameterMplayer);
|
|
|
|
this.addParameter(TypeDouble.get(), "#");
|
2012-01-28 18:56:51 +01:00
|
|
|
}
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
2012-01-28 18:56:51 +01:00
|
|
|
|
|
|
|
@Override
|
2015-02-12 12:00:55 +01:00
|
|
|
public void perform() throws MassiveException
|
2012-01-28 18:56:51 +01:00
|
|
|
{
|
2015-05-06 17:04:35 +02:00
|
|
|
String type = this.<String>readArg().toLowerCase();
|
2013-04-25 07:53:21 +02: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;
|
|
|
|
}
|
2012-01-28 18:56:51 +01:00
|
|
|
|
2015-05-06 17:04:35 +02:00
|
|
|
double targetPower = this.readArgAt(2);
|
2012-01-28 18:56:51 +01:00
|
|
|
|
2013-04-25 07:53:21 +02:00
|
|
|
String target;
|
|
|
|
|
|
|
|
if (doPlayer)
|
|
|
|
{
|
2015-10-21 19:35:41 +02:00
|
|
|
this.getParameters().set(1, parameterMplayer);
|
2015-05-06 17:04:35 +02:00
|
|
|
MPlayer targetPlayer = this.readArgAt(1);
|
2013-04-25 07:53:21 +02:00
|
|
|
|
|
|
|
targetPlayer.setPowerBoost(targetPower);
|
|
|
|
target = "Player \""+targetPlayer.getName()+"\"";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-21 19:35:41 +02:00
|
|
|
this.getParameters().set(1, parameterFaction);
|
2015-05-06 17:04:35 +02:00
|
|
|
Faction targetFaction = this.readArgAt(1);
|
2013-04-25 07:53:21 +02:00
|
|
|
|
|
|
|
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+".");
|
2012-01-28 18:56:51 +01:00
|
|
|
}
|
2013-11-11 09:31:04 +01:00
|
|
|
|
2012-01-28 18:56:51 +01:00
|
|
|
}
|