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-22 17:59:51 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARUPlayer;
|
|
|
|
import com.massivecraft.factions.entity.UPlayer;
|
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 CmdFactionsPromote extends FCommand
|
2013-01-06 21:44:29 +01:00
|
|
|
{
|
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsPromote()
|
2013-01-06 21:44:29 +01:00
|
|
|
{
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addAliases("promote");
|
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.PROMOTE.node));
|
2013-01-06 21:44:29 +01:00
|
|
|
|
|
|
|
//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()
|
|
|
|
{
|
2013-04-22 17:59:51 +02:00
|
|
|
UPlayer you = this.arg(0, ARUPlayer.getStartAny(sender));
|
2013-01-06 21:44:29 +01:00
|
|
|
if (you == null) return;
|
|
|
|
|
2013-04-25 07:29:19 +02:00
|
|
|
if (you.getFaction() != usenderFaction)
|
2013-01-06 21:44:29 +01:00
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
msg("%s<b> is not a member in your faction.", you.describeTo(usender, true));
|
2013-01-06 21:44:29 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-25 07:29:19 +02:00
|
|
|
if (you == usender)
|
2013-01-06 21:44:29 +01:00
|
|
|
{
|
|
|
|
msg("<b>The target player mustn't be yourself.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (you.getRole() == Rel.RECRUIT)
|
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
if (!usender.getRole().isAtLeast(Rel.OFFICER))
|
2013-04-19 15:01:53 +02:00
|
|
|
{
|
2013-01-06 21:44:29 +01:00
|
|
|
msg("<b>You must be an officer to promote someone to member.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
you.setRole(Rel.MEMBER);
|
2013-04-25 07:29:19 +02:00
|
|
|
usenderFaction.msg("%s<i> was promoted to being a member of your faction.", you.describeTo(usenderFaction, true));
|
2013-01-06 21:44:29 +01:00
|
|
|
}
|
|
|
|
else if (you.getRole() == Rel.MEMBER)
|
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
if (!usender.getRole().isAtLeast(Rel.LEADER))
|
2013-04-19 15:01:53 +02:00
|
|
|
{
|
2013-01-06 21:44:29 +01:00
|
|
|
msg("<b>You must be the leader to promote someone to officer.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Give
|
|
|
|
you.setRole(Rel.OFFICER);
|
2013-04-25 07:29:19 +02:00
|
|
|
usenderFaction.msg("%s<i> was promoted to being a officer in your faction.", you.describeTo(usenderFaction, true));
|
2013-01-06 21:44:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|