Factions/src/com/massivecraft/factions/cmd/CmdOfficer.java
Brettflan bc40f3b751 Server admins can now promote or demote any member of any faction to/from faction leader or officer using the existing /f leader and /f officer commands, with two new permissions added to allow that. A third permission is also added to allow server admins or moderators to join any faction without the need of /f bypass mode.
Also, a couple more minor bugfixes are included for /f home payment giving the wrong message, player/faction descriptions being wrong for console messages, and potential NPE in new faction leader promotion routine if faction was permanent with no current leader.

New permissions:
factions.leader.any - allows use of /f leader on any player in any faction
factions officer.any - allows use of /f officer on any player in any faction
factions.join.any - allows player to join any faction, bypassing invitation process for closed factions (the same as players with /f bypass enabled can do)
2012-01-18 06:01:50 -06:00

78 lines
1.8 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel;
public class CmdOfficer extends FCommand
{
public CmdOfficer()
{
super();
this.aliases.add("officer");
this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
this.permission = Permission.OFFICER.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
}
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
boolean permAny = Permission.OFFICER_ANY.has(sender, false);
Faction targetFaction = you.getFaction();
if (targetFaction != myFaction && !permAny)
{
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
return;
}
if (fme != null && fme.getRole() != Rel.LEADER && !permAny)
{
msg("<b>You are not the faction leader.");
return;
}
if (you == fme && !permAny)
{
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(fme, 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(fme, true));
}
}
}