2013-01-06 21:44:29 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2013-04-09 12:56:29 +02:00
|
|
|
import com.massivecraft.factions.Perm;
|
2013-04-09 13:24:55 +02:00
|
|
|
import com.massivecraft.factions.Rel;
|
2013-04-16 11:05:49 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.FPlayer;
|
2013-04-16 10:11:59 +02:00
|
|
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
2013-01-06 21:44:29 +01:00
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public class CmdFactionsDemote extends FCommand
|
2013-01-06 21:44:29 +01:00
|
|
|
{
|
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsDemote()
|
2013-01-06 21:44:29 +01:00
|
|
|
{
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addAliases("demote");
|
2013-01-06 21:44:29 +01:00
|
|
|
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addRequiredArg("player");
|
2013-01-06 21:44:29 +01:00
|
|
|
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.DEMOTE.node));
|
2013-01-06 21:44:29 +01:00
|
|
|
|
|
|
|
//To demote someone from member -> recruit you must be an officer.
|
|
|
|
//To demote someone from officer -> member you must be a leader.
|
|
|
|
//We'll handle this internally
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform()
|
|
|
|
{
|
2013-04-16 11:05:49 +02:00
|
|
|
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
|
2013-01-06 21:44:29 +01:00
|
|
|
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.MEMBER)
|
|
|
|
{
|
2013-04-19 15:01:53 +02:00
|
|
|
if (!fme.getRole().isAtLeast(Rel.OFFICER))
|
|
|
|
{
|
2013-01-06 21:44:29 +01:00
|
|
|
msg("<b>You must be an officer to demote a member to recruit.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
you.setRole(Rel.RECRUIT);
|
|
|
|
myFaction.msg("%s<i> was demoted to being a recruit in your faction.", you.describeTo(myFaction, true));
|
|
|
|
}
|
|
|
|
else if (you.getRole() == Rel.OFFICER)
|
|
|
|
{
|
2013-04-19 15:01:53 +02:00
|
|
|
if (!fme.getRole().isAtLeast(Rel.LEADER))
|
|
|
|
{
|
2013-01-06 21:44:29 +01:00
|
|
|
msg("<b>You must be the leader to demote an officer to member.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
you.setRole(Rel.MEMBER);
|
|
|
|
myFaction.msg("%s<i> was demoted to being a member in your faction.", you.describeTo(myFaction, true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|