Add recruit role for factions

The recruit role's goal is to enable factions to invite new members without being afraid of getting griefed instantly.

Adds a configuration option "factionRankDefault" for default rank of newly joined faction members. By default this is RECRUIT, but it can be set to any supported rank.

Adds the /f promote and /f demote commands, which leaders and officers can use to increase or decrease the rank of a faction member by one level, up to officer, or down to recruit.
This version of the recruit feature preserves the /f officer command for backward compatibility.
This commit is contained in:
Justin Kaeser
2013-01-06 21:44:29 +01:00
parent 755a957b12
commit 4743c1821a
13 changed files with 208 additions and 31 deletions

View File

@ -0,0 +1,68 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel;
public class CmdDemote extends FCommand
{
public CmdDemote()
{
super();
this.aliases.add("demote");
this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
this.permission = Permission.DEMOTE.node;
this.disableOnLock = true;
//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
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
}
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
if (you.getFaction() != myFaction)
{
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
return;
}
if (you == fme)
{
msg("<b>The target player mustn't be yourself.");
return;
}
if (you.getRole() == Rel.MEMBER)
{
if (!fme.getRole().isAtLeast(Rel.OFFICER)) {
msg("<b>You must be an officer to demote a member to recruit.");
return;
}
you.setRole(Rel.RECRUIT);
myFaction.msg("%s<i> was demoted to being a recruit in your faction.", you.describeTo(myFaction, true));
}
else if (you.getRole() == Rel.OFFICER)
{
if (!fme.getRole().isAtLeast(Rel.LEADER)) {
msg("<b>You must be the leader to demote an officer to member.");
return;
}
you.setRole(Rel.MEMBER);
myFaction.msg("%s<i> was demoted to being a member in your faction.", you.describeTo(myFaction, true));
}
}
}

View File

@ -103,6 +103,8 @@ public class CmdHelp extends FCommand
pageLines.add( p.cmdBase.cmdUnclaim.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdUnclaimall.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdKick.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdPromote.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdDemote.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdOfficer.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdLeader.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdTitle.getUseageTemplate(true) );

View File

@ -3,9 +3,9 @@ package com.massivecraft.factions.cmd;
import org.bukkit.Bukkit;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P;
import com.massivecraft.factions.event.FPlayerJoinEvent;
import com.massivecraft.factions.struct.Permission;
@ -87,15 +87,18 @@ public class CmdJoin extends FCommand
// then make 'em pay (if applicable)
if (samePlayer && ! payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) return;
fme.msg("<i>%s successfully joined %s.", fplayer.describeTo(fme, true), faction.getTag(fme));
fme.setRole(Conf.factionRankDefault); // They have just joined a faction, start them out on the lowest rank (default config).
if (!samePlayer)
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
fme.msg("<i>%s successfully joined %s.", fplayer.describeTo(fme, true), faction.getTag(fme));
fplayer.resetFactionData();
fplayer.setFaction(faction);
faction.deinvite(fplayer);
if (Conf.logFactionJoin)
{

View File

@ -0,0 +1,69 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel;
public class CmdPromote extends FCommand
{
public CmdPromote()
{
super();
this.aliases.add("promote");
this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
this.permission = Permission.PROMOTE.node;
this.disableOnLock = true;
//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
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeOfficer = false;
senderMustBeLeader = false;
}
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
if (you.getFaction() != myFaction)
{
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
return;
}
if (you == fme)
{
msg("<b>The target player mustn't be yourself.");
return;
}
if (you.getRole() == Rel.RECRUIT)
{
if (!fme.getRole().isAtLeast(Rel.OFFICER)) {
msg("<b>You must be an officer to promote someone to member.");
return;
}
you.setRole(Rel.MEMBER);
myFaction.msg("%s<i> was promoted to being a member of your faction.", you.describeTo(myFaction, true));
}
else if (you.getRole() == Rel.MEMBER)
{
if (!fme.getRole().isAtLeast(Rel.LEADER)) {
msg("<b>You must be the leader to promote someone to officer.");
return;
}
// Give
you.setRole(Rel.OFFICER);
myFaction.msg("%s<i> was promoted to being a officer in your faction.", you.describeTo(myFaction, true));
}
}
}

View File

@ -49,6 +49,7 @@ public class CmdShow extends FCommand
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Rel.LEADER);
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Rel.OFFICER);
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Rel.MEMBER);
Collection<FPlayer> recruits = faction.getFPlayersWhereRole(Rel.RECRUIT);
msg(p.txt.titleize(faction.getTag(fme)));
msg("<a>Description: <i>%s", faction.getDescription());
@ -147,6 +148,17 @@ public class CmdShow extends FCommand
}
}
for (FPlayer follower : recruits)
{
if (follower.isOnline())
{
memberOnlineNames.add(follower.getNameAndTitle(fme));
}
else
{
memberOfflineNames.add(follower.getNameAndTitle(fme));
}
}
sendMessage(p.txt.parse("<a>Members online: ") + TextUtil.implode(memberOnlineNames, sepparator));
sendMessage(p.txt.parse("<a>Members offline: ") + TextUtil.implode(memberOfflineNames, sepparator));
}

View File

@ -16,6 +16,7 @@ public class FCmdRoot extends FCommand
public CmdConfig cmdConfig = new CmdConfig();
public CmdCreate cmdCreate = new CmdCreate();
public CmdDeinvite cmdDeinvite = new CmdDeinvite();
public CmdDemote cmdDemote = new CmdDemote();
public CmdDescription cmdDescription = new CmdDescription();
public CmdDisband cmdDisband = new CmdDisband();
public CmdFlag cmdFlag = new CmdFlag();
@ -33,6 +34,7 @@ public class FCmdRoot extends FCommand
public CmdPerm cmdPerm = new CmdPerm();
public CmdPower cmdPower = new CmdPower();
public CmdPowerBoost cmdPowerBoost = new CmdPowerBoost();
public CmdPromote cmdPromote = new CmdPromote();
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy();
public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral();
@ -77,6 +79,7 @@ public class FCmdRoot extends FCommand
this.addSubCommand(this.cmdCreate);
this.addSubCommand(this.cmdSethome);
this.addSubCommand(this.cmdTag);
this.addSubCommand(this.cmdDemote);
this.addSubCommand(this.cmdDescription);
this.addSubCommand(this.cmdCape);
this.addSubCommand(this.cmdPerm);
@ -103,6 +106,7 @@ public class FCmdRoot extends FCommand
this.addSubCommand(this.cmdRelationTruce);
this.addSubCommand(this.cmdBypass);
this.addSubCommand(this.cmdPowerBoost);
this.addSubCommand(this.cmdPromote);
this.addSubCommand(this.cmdLock);
this.addSubCommand(this.cmdReload);
this.addSubCommand(this.cmdConfig);