Factions3/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java

78 lines
2.0 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
2013-04-25 13:25:15 +02:00
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
2013-04-10 13:12:22 +02:00
public class CmdFactionsDemote extends FCommand
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2013-04-10 13:12:22 +02:00
public CmdFactionsDemote()
{
2013-11-11 09:31:04 +01:00
// Aliases
2013-04-16 10:11:59 +02:00
this.addAliases("demote");
2013-11-11 09:31:04 +01:00
// Args
this.addRequiredArg("player");
2013-11-11 09:31:04 +01:00
// Requirements
2013-04-25 13:25:15 +02:00
this.addRequirements(ReqFactionsEnabled.get());
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.DEMOTE.node));
//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
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
2013-04-25 13:25:15 +02:00
{
UPlayer you = this.arg(0, ARUPlayer.getAny(usender));
if (you == null) return;
if (you.getFaction() != usenderFaction)
{
msg("%s<b> is not a member in your faction.", you.describeTo(usender, true));
return;
}
if (you == usender)
{
msg("<b>The target player mustn't be yourself.");
return;
}
if (you.getRole() == Rel.MEMBER)
{
if (!usender.getRole().isAtLeast(Rel.OFFICER))
{
msg("<b>You must be an officer to demote a member to recruit.");
return;
}
you.setRole(Rel.RECRUIT);
usenderFaction.msg("%s<i> was demoted to being a recruit in your faction.", you.describeTo(usenderFaction, true));
}
else if (you.getRole() == Rel.OFFICER)
{
if (!usender.getRole().isAtLeast(Rel.LEADER))
{
msg("<b>You must be the leader to demote an officer to member.");
return;
}
you.setRole(Rel.MEMBER);
usenderFaction.msg("%s<i> was demoted to being a member in your faction.", you.describeTo(usenderFaction, true));
}
}
}