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

77 lines
1.9 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
2014-09-17 13:29:58 +02:00
import com.massivecraft.factions.cmd.arg.ARMPlayer;
import com.massivecraft.factions.entity.MPlayer;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
2014-09-18 13:41:20 +02:00
public class CmdFactionsPromote extends FactionsCommand
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2013-04-10 13:12:22 +02:00
public CmdFactionsPromote()
{
2013-11-11 09:31:04 +01:00
// Aliases
2013-04-16 10:11:59 +02:00
this.addAliases("promote");
2013-11-11 09:31:04 +01:00
// Args
this.addRequiredArg("player");
2013-11-11 09:31:04 +01:00
// Requirements
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
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
2014-09-17 13:29:58 +02:00
MPlayer you = this.arg(0, ARMPlayer.getAny());
if (you == null) return;
2014-09-18 13:41:20 +02:00
if (you.getFaction() != msenderFaction)
{
2014-09-18 13:41:20 +02:00
msg("%s<b> is not a member in your faction.", you.describeTo(msender, true));
return;
}
2014-09-18 13:41:20 +02:00
if (you == msender)
{
msg("<b>The target player mustn't be yourself.");
return;
}
if (you.getRole() == Rel.RECRUIT)
{
2014-09-18 13:41:20 +02:00
if (!msender.getRole().isAtLeast(Rel.OFFICER))
{
msg("<b>You must be an officer to promote someone to member.");
return;
}
you.setRole(Rel.MEMBER);
2014-09-18 13:41:20 +02:00
msenderFaction.msg("%s<i> was promoted to being a member of your faction.", you.describeTo(msenderFaction, true));
}
else if (you.getRole() == Rel.MEMBER)
{
2014-09-18 13:41:20 +02:00
if (!msender.getRole().isAtLeast(Rel.LEADER))
{
msg("<b>You must be the leader to promote someone to officer.");
return;
}
// Give
you.setRole(Rel.OFFICER);
2014-09-18 13:41:20 +02:00
msenderFaction.msg("%s<i> was promoted to being a officer in your faction.", you.describeTo(msenderFaction, true));
}
}
}