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;
|
2014-09-17 13:29:58 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
2013-04-16 11:27:03 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
2014-09-17 13:17:33 +02:00
|
|
|
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-05-06 17:04:35 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.ArgSetting;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.arg.ARDouble;
|
2015-05-06 17:04:35 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.arg.ARString;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
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-05-13 23:00:53 +02:00
|
|
|
private ArgSetting<MPlayer> settingMplayer = new ArgSetting<MPlayer>(ARMPlayer.getAny(), "name");
|
|
|
|
private ArgSetting<Faction> settingFaction = new ArgSetting<Faction>(ARFaction.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
|
|
|
{
|
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
|
|
|
|
|
|
|
// Args
|
2015-05-06 17:04:35 +02:00
|
|
|
this.addArg(ARString.get(), "p|f|player|faction");
|
2015-05-13 23:00:53 +02:00
|
|
|
this.addArg(settingMplayer);
|
2015-05-06 17:04:35 +02:00
|
|
|
this.addArg(ARDouble.get(), "#");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Requirements
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node));
|
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-05-13 23:00:53 +02:00
|
|
|
this.getArgSettings().set(1, settingMplayer);
|
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-05-13 23:00:53 +02:00
|
|
|
this.getArgSettings().set(1, settingFaction);
|
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
|
|
|
}
|