2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
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;
|
2013-04-25 13:25:15 +02:00
|
|
|
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
|
2013-04-22 17:59:51 +02:00
|
|
|
import com.massivecraft.factions.entity.UPlayer;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2013-04-16 10:11:59 +02:00
|
|
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public class CmdFactionsOfficer extends FCommand
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsOfficer()
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addAliases("officer");
|
2011-03-22 18:48:09 +01:00
|
|
|
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addRequiredArg("player");
|
2011-03-22 15:45:41 +01:00
|
|
|
|
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.OFFICER.node));
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-10-09 14:53:38 +02:00
|
|
|
public void perform()
|
|
|
|
{
|
2013-04-22 17:59:51 +02:00
|
|
|
UPlayer you = this.arg(0, ARUPlayer.getStartAny(sender));
|
2011-10-09 14:53:38 +02:00
|
|
|
if (you == null) return;
|
2012-01-18 13:01:50 +01:00
|
|
|
|
2013-04-09 12:56:29 +02:00
|
|
|
boolean permAny = Perm.OFFICER_ANY.has(sender, false);
|
2012-01-18 13:01:50 +01:00
|
|
|
Faction targetFaction = you.getFaction();
|
|
|
|
|
2013-04-25 07:29:19 +02:00
|
|
|
if (targetFaction != usenderFaction && !permAny)
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
msg("%s<b> is not a member in your faction.", you.describeTo(usender, true));
|
2011-03-22 15:45:41 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-25 07:29:19 +02:00
|
|
|
if (usender != null && usender.getRole() != Rel.LEADER && !permAny)
|
2012-01-18 13:01:50 +01:00
|
|
|
{
|
|
|
|
msg("<b>You are not the faction leader.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-25 07:29:19 +02:00
|
|
|
if (you == usender && !permAny)
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2011-10-10 13:40:24 +02:00
|
|
|
msg("<b>The target player musn't be yourself.");
|
2011-03-22 15:45:41 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-18 13:01:50 +01:00
|
|
|
if (you.getRole() == Rel.LEADER)
|
|
|
|
{
|
|
|
|
msg("<b>The target player is a faction leader. Demote them first.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-23 17:30:41 +02:00
|
|
|
if (you.getRole() == Rel.OFFICER)
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2011-03-22 15:45:41 +01:00
|
|
|
// Revoke
|
2011-10-23 17:30:41 +02:00
|
|
|
you.setRole(Rel.MEMBER);
|
2012-01-18 13:01:50 +01:00
|
|
|
targetFaction.msg("%s<i> is no longer officer in your faction.", you.describeTo(targetFaction, true));
|
2013-04-25 07:29:19 +02:00
|
|
|
msg("<i>You have removed officer status from %s<i>.", you.describeTo(usender, true));
|
2011-10-09 14:53:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-22 15:45:41 +01:00
|
|
|
// Give
|
2011-10-23 17:30:41 +02:00
|
|
|
you.setRole(Rel.OFFICER);
|
2012-01-18 13:01:50 +01:00
|
|
|
targetFaction.msg("%s<i> was promoted to officer in your faction.", you.describeTo(targetFaction, true));
|
2013-04-25 07:29:19 +02:00
|
|
|
msg("<i>You have promoted %s<i> to officer.", you.describeTo(usender, true));
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|