Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdPower.java

55 lines
1.7 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
2011-10-09 18:35:39 +02:00
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
2014-04-04 20:55:21 +02:00
public class CmdPower extends FCommand {
public CmdPower() {
2014-07-01 22:10:18 +02:00
super();
this.aliases.add("power");
this.aliases.add("pow");
2014-04-04 20:55:21 +02:00
//this.requiredArgs.add("faction tag");
this.optionalArgs.put("player name", "you");
2014-07-01 22:10:18 +02:00
this.permission = Permission.POWER.node;
this.disableOnLock = false;
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +02:00
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
2018-03-26 23:43:15 +02:00
senderMustBeColeader = false;
2014-04-04 20:55:21 +02:00
senderMustBeAdmin = false;
}
@Override
public void perform() {
2014-07-01 22:10:18 +02:00
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
if (target == null) {
return;
}
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +02:00
if (target != fme && !Permission.POWER_ANY.has(sender, true)) {
return;
}
2014-04-04 20:55:21 +02:00
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
2014-12-11 17:05:04 +01:00
if (!payForCommand(Conf.econCostPower, TL.COMMAND_POWER_TOSHOW, TL.COMMAND_POWER_FORSHOW)) {
2014-07-01 21:49:42 +02:00
return;
}
2014-04-04 20:55:21 +02:00
double powerBoost = target.getPowerBoost();
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_POWER_BONUS.toString() : TL.COMMAND_POWER_PENALTY.toString()) + powerBoost + ")";
msg(TL.COMMAND_POWER_POWER, target.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost);
2014-04-04 20:55:21 +02:00
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_POWER_DESCRIPTION;
}
}