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

64 lines
1.7 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
2019-06-29 03:49:46 +02:00
import com.massivecraft.factions.SaberFactions;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdPermanent extends FCommand {
public CmdPermanent() {
super();
this.aliases.add("permanent");
this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
this.permission = Permission.SET_PERMANENT.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
Faction faction = this.argAsFaction(0);
if (faction == null) {
return;
}
String change;
if (faction.isPermanent()) {
change = TL.COMMAND_PERMANENT_REVOKE.toString();
faction.setPermanent(false);
} else {
change = TL.COMMAND_PERMANENT_GRANT.toString();
faction.setPermanent(true);
}
2019-06-29 03:49:46 +02:00
SaberFactions.plugin.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\".");
// Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
String blame = (fme == null ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer, true));
if (fplayer.getFaction() == faction) {
fplayer.msg(TL.COMMAND_PERMANENT_YOURS, blame, change);
} else {
fplayer.msg(TL.COMMAND_PERMANENT_OTHER, blame, change, faction.getTag(fplayer));
}
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_PERMANENT_DESCRIPTION;
}
}