Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdPermanentPower.java
Nick Porillo 0aea7c6b9d Remove redundant messaging. Fixes #276
When informing faction members, if the command sender is part of the
faction, do not send another message to him because he has already been
informed.
2015-02-20 12:47:48 -06:00

59 lines
1.8 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdPermanentPower extends FCommand {
public CmdPermanentPower() {
super();
this.aliases.add("permanentpower");
this.requiredArgs.add("faction");
this.optionalArgs.put("power", "reset");
this.permission = Permission.SET_PERMANENTPOWER.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
Faction targetFaction = this.argAsFaction(0);
if (targetFaction == null) {
return;
}
Integer targetPower = this.argAsInt(1);
targetFaction.setPermanentPower(targetPower);
String change = TL.COMMAND_PERMANENTPOWER_REVOKE.toString();
if (targetFaction.hasPermanentPower()) {
change = TL.COMMAND_PERMANENTPOWER_GRANT.toString();
}
// Inform sender
msg(TL.COMMAND_PERMANENTPOWER_SUCCESS, change, targetFaction.describeTo(fme));
// Inform all other players
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) {
if(fplayer == fme) {
continue;
}
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true));
fplayer.msg(TL.COMMAND_PERMANENTPOWER_FACTION, blame, change);
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_PERMANENTPOWER_DESCRIPTION;
}
}