Saber-Factions/src/com/massivecraft/factions/cmd/CmdPermanent.java
Brettflan 7138e8d5f8 Added possibility to specify a player in the /f join command (/f join <faction> [player=you]), to make a player other than yourself join the specified faction. The new permission factions.join.others (added to factions.kit.mod and above) is required to be able to specify a different player.
Note that the player cannot currently already be in another faction; if they are, you'll need to /f kick them first. Also note that if the faction isn't open (with no invitation required), the player isn't invited, and you don't have the factions.join.any permission or have admin bypass mode on, the attempt will also fail.

Also, added new log method which accepts arguments (like the msg method) and cleaned up /f permanent text a little.
2012-02-26 12:29:46 -06:00

63 lines
1.6 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
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;
senderMustBeAdmin = false;
}
@Override
public void perform()
{
Faction faction = this.argAsFaction(0);
if (faction == null) return;
String change;
if(faction.isPermanent())
{
change = "removed permanent status from";
faction.setPermanent(false);
}
else
{
change = "added permanent status to";
faction.setPermanent(true);
}
P.p.log((fme == null ? "A server admin" : fme.getName())+" "+change+" the faction \"" + faction.getTag() + "\".");
// Inform all players
for (FPlayer fplayer : FPlayers.i.getOnline())
{
if (fplayer.getFaction() == faction)
{
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> "+change+" your faction.");
}
else
{
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
}
}
}
}