Factions/src/com/massivecraft/factions/cmd/CmdFactionsPromote.java

64 lines
1.6 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
2013-04-16 10:11:59 +02:00
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
2013-04-10 13:12:22 +02:00
public class CmdFactionsPromote extends FCommand
{
2013-04-10 13:12:22 +02:00
public CmdFactionsPromote()
{
2013-04-16 10:11:59 +02:00
this.addAliases("promote");
this.addRequiredArg("player");
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.PROMOTE.node));
//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
}
@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));
}
}
}