Factions/src/com/massivecraft/factions/cmd/CmdPromote.java
Justin Kaeser 4743c1821a Add recruit role for factions
The recruit role's goal is to enable factions to invite new members without being afraid of getting griefed instantly.

Adds a configuration option "factionRankDefault" for default rank of newly joined faction members. By default this is RECRUIT, but it can be set to any supported rank.

Adds the /f promote and /f demote commands, which leaders and officers can use to increase or decrease the rank of a faction member by one level, up to officer, or down to recruit.
This version of the recruit feature preserves the /f officer command for backward compatibility.
2013-01-06 21:44:29 +01:00

70 lines
1.7 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel;
public class CmdPromote extends FCommand
{
public CmdPromote()
{
super();
this.aliases.add("promote");
this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
this.permission = Permission.PROMOTE.node;
this.disableOnLock = true;
//To promote someone from recruit -> member you must be an officer.
//To promote someone from member -> officer you must be a leader.
//We'll handle this internally
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
}
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
if (you.getFaction() != myFaction)
{
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
return;
}
if (you == fme)
{
msg("<b>The target player mustn't be yourself.");
return;
}
if (you.getRole() == Rel.RECRUIT)
{
if (!fme.getRole().isAtLeast(Rel.OFFICER)) {
msg("<b>You must be an officer to promote someone to member.");
return;
}
you.setRole(Rel.MEMBER);
myFaction.msg("%s<i> was promoted to being a member of your faction.", you.describeTo(myFaction, true));
}
else if (you.getRole() == Rel.MEMBER)
{
if (!fme.getRole().isAtLeast(Rel.LEADER)) {
msg("<b>You must be the leader to promote someone to officer.");
return;
}
// Give
you.setRole(Rel.OFFICER);
myFaction.msg("%s<i> was promoted to being a officer in your faction.", you.describeTo(myFaction, true));
}
}
}