2011-10-22 18:12:15 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
2014-04-04 20:55:21 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2011-10-22 18:12:15 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2015-01-22 00:58:33 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2011-10-22 18:12:15 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public class CmdPermanentPower extends FCommand {
|
|
|
|
public CmdPermanentPower() {
|
2014-07-01 22:10:18 +02:00
|
|
|
super();
|
|
|
|
this.aliases.add("permanentpower");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.requiredArgs.add("faction");
|
2018-01-05 08:01:52 +01:00
|
|
|
this.requiredArgs.add("power");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.SET_PERMANENTPOWER.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;
|
2014-04-04 20:55:21 +02:00
|
|
|
senderMustBeAdmin = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
2014-07-01 22:10:18 +02:00
|
|
|
Faction targetFaction = this.argAsFaction(0);
|
|
|
|
if (targetFaction == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
Integer targetPower = this.argAsInt(1);
|
|
|
|
|
|
|
|
targetFaction.setPermanentPower(targetPower);
|
|
|
|
|
2015-01-22 00:58:33 +01:00
|
|
|
String change = TL.COMMAND_PERMANENTPOWER_REVOKE.toString();
|
2014-07-01 22:10:18 +02:00
|
|
|
if (targetFaction.hasPermanentPower()) {
|
2015-01-22 00:58:33 +01:00
|
|
|
change = TL.COMMAND_PERMANENTPOWER_GRANT.toString();
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2015-02-19 16:49:38 +01:00
|
|
|
// Inform sender
|
2015-01-22 00:58:33 +01:00
|
|
|
msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(fme));
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2015-02-19 16:49:38 +01:00
|
|
|
// Inform all other players
|
2014-04-04 20:55:21 +02:00
|
|
|
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) {
|
2015-05-13 06:17:22 +02:00
|
|
|
if (fplayer == fme) {
|
2015-02-19 16:49:38 +01:00
|
|
|
continue;
|
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true));
|
|
|
|
fplayer.msg(TL.COMMAND_PERMANENTPOWER_FACTION, blame, change);
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_PERMANENTPOWER_DESCRIPTION;
|
|
|
|
}
|
2011-10-22 18:12:15 +02:00
|
|
|
}
|