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

82 lines
2.0 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
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;
2013-04-22 09:37:53 +02:00
import com.massivecraft.factions.entity.Faction;
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 CmdFactionsOfficer extends FCommand
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2013-04-10 13:12:22 +02:00
public CmdFactionsOfficer()
{
2013-11-11 09:31:04 +01:00
// Aliases
2013-04-16 10:11:59 +02:00
this.addAliases("officer");
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.OFFICER.node));
}
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;
boolean permAny = Perm.OFFICER_ANY.has(sender, false);
Faction targetFaction = you.getFaction();
if (targetFaction != usenderFaction && !permAny)
{
msg("%s<b> is not a member in your faction.", you.describeTo(usender, true));
return;
}
if (usender != null && usender.getRole() != Rel.LEADER && !permAny)
{
msg("<b>You are not the faction leader.");
return;
}
if (you == usender && !permAny)
{
2011-10-10 13:40:24 +02:00
msg("<b>The target player musn't be yourself.");
return;
}
if (you.getRole() == Rel.LEADER)
{
msg("<b>The target player is a faction leader. Demote them first.");
return;
}
if (you.getRole() == Rel.OFFICER)
{
// Revoke
you.setRole(Rel.MEMBER);
targetFaction.msg("%s<i> is no longer officer in your faction.", you.describeTo(targetFaction, true));
msg("<i>You have removed officer status from %s<i>.", you.describeTo(usender, true));
}
else
{
// Give
you.setRole(Rel.OFFICER);
targetFaction.msg("%s<i> was promoted to officer in your faction.", you.describeTo(targetFaction, true));
msg("<i>You have promoted %s<i> to officer.", you.describeTo(usender, true));
}
}
}