2012-01-28 18:58:18 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
2014-04-04 20:55:21 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2018-10-23 01:42:57 +02:00
|
|
|
import com.massivecraft.factions.SavageFactions;
|
2012-01-28 18:58:18 +01:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2012-01-28 18:58:18 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public class CmdPowerBoost extends FCommand {
|
2014-08-05 17:17:27 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public CmdPowerBoost() {
|
2014-07-01 22:10:18 +02:00
|
|
|
super();
|
|
|
|
this.aliases.add("powerboost");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2018-11-07 06:38:43 +01:00
|
|
|
this.requiredArgs.add("plugin|f|player|faction");
|
2014-07-01 22:10:18 +02:00
|
|
|
this.requiredArgs.add("name");
|
2015-12-03 01:26:06 +01:00
|
|
|
this.requiredArgs.add("# or reset");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.POWERBOOST.node;
|
|
|
|
this.disableOnLock = true;
|
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
|
|
|
String type = this.argAsString(0).toLowerCase();
|
|
|
|
boolean doPlayer = true;
|
2014-04-04 20:55:21 +02:00
|
|
|
if (type.equals("f") || type.equals("faction")) {
|
|
|
|
doPlayer = false;
|
2018-11-07 17:14:42 +01:00
|
|
|
} else if (!type.equals("plugin") && !type.equals("player")) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_POWERBOOST_HELP_1);
|
|
|
|
msg(TL.COMMAND_POWERBOOST_HELP_2);
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
Double targetPower = this.argAsDouble(2);
|
|
|
|
if (targetPower == null) {
|
2015-12-03 01:26:06 +01:00
|
|
|
if (this.argAsString(2).equalsIgnoreCase("reset")) {
|
|
|
|
targetPower = 0D;
|
|
|
|
} else {
|
|
|
|
msg(TL.COMMAND_POWERBOOST_INVALIDNUM);
|
|
|
|
return;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2012-01-28 18:58:18 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
String target;
|
2012-01-28 18:58:18 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
if (doPlayer) {
|
2014-07-01 22:10:18 +02:00
|
|
|
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1);
|
|
|
|
if (targetPlayer == null) {
|
|
|
|
return;
|
|
|
|
}
|
2015-08-09 04:53:31 +02:00
|
|
|
|
2015-12-03 01:26:06 +01:00
|
|
|
if (targetPower != 0) {
|
|
|
|
targetPower += targetPlayer.getPowerBoost();
|
|
|
|
}
|
2014-07-01 22:10:18 +02:00
|
|
|
targetPlayer.setPowerBoost(targetPower);
|
2014-12-08 00:12:52 +01:00
|
|
|
target = TL.COMMAND_POWERBOOST_PLAYER.format(targetPlayer.getName());
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-07-01 22:10:18 +02:00
|
|
|
Faction targetFaction = this.argAsFaction(1);
|
|
|
|
if (targetFaction == null) {
|
|
|
|
return;
|
|
|
|
}
|
2015-08-09 04:53:31 +02:00
|
|
|
|
2015-12-03 01:26:06 +01:00
|
|
|
if (targetPower != 0) {
|
|
|
|
targetPower += targetFaction.getPowerBoost();
|
|
|
|
}
|
2014-07-01 22:10:18 +02:00
|
|
|
targetFaction.setPowerBoost(targetPower);
|
2014-12-08 00:12:52 +01:00
|
|
|
target = TL.COMMAND_POWERBOOST_FACTION.format(targetFaction.getTag());
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2012-01-28 18:58:18 +01:00
|
|
|
|
2015-05-13 06:17:22 +02:00
|
|
|
int roundedPower = (int) Math.round(targetPower);
|
2014-12-24 11:15:16 +01:00
|
|
|
msg(TL.COMMAND_POWERBOOST_BOOST, target, roundedPower);
|
2018-11-07 17:14:42 +01:00
|
|
|
if (!senderIsConsole) {
|
2018-11-07 06:38:43 +01:00
|
|
|
SavageFactions.plugin.log(TL.COMMAND_POWERBOOST_BOOSTLOG.toString(), fme.getName(), target, roundedPower);
|
2014-07-01 21:49:42 +02:00
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_POWERBOOST_DESCRIPTION;
|
|
|
|
}
|
2012-01-28 18:58:18 +01:00
|
|
|
}
|