2015-01-13 13:50:38 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Perm;
|
|
|
|
import com.massivecraft.factions.Rel;
|
2015-10-21 19:35:41 +02:00
|
|
|
import com.massivecraft.factions.cmd.type.TypeFaction;
|
2015-01-13 13:50:38 +01:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
|
|
|
import com.massivecraft.factions.entity.MPerm;
|
|
|
|
import com.massivecraft.factions.entity.MPlayer;
|
2015-02-12 12:00:55 +01:00
|
|
|
import com.massivecraft.massivecore.MassiveException;
|
2015-10-21 19:35:41 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.Parameter;
|
2015-01-13 13:50:38 +01:00
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
2015-09-05 13:44:24 +02:00
|
|
|
import com.massivecraft.massivecore.pager.Pager;
|
2015-01-13 13:50:38 +01:00
|
|
|
import com.massivecraft.massivecore.pager.Stringifier;
|
|
|
|
import com.massivecraft.massivecore.util.Txt;
|
|
|
|
|
|
|
|
public class CmdFactionsInviteList extends FactionsCommand
|
|
|
|
{
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
public CmdFactionsInviteList()
|
|
|
|
{
|
|
|
|
// Aliases
|
|
|
|
this.addAliases("l", "list");
|
|
|
|
|
2015-10-21 19:35:41 +02:00
|
|
|
// Parameters
|
|
|
|
this.addParameter(Parameter.getPage());
|
|
|
|
this.addParameter(TypeFaction.get(), "faction", "you");
|
2015-01-13 13:50:38 +01:00
|
|
|
|
|
|
|
// Requirements
|
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.INVITE_LIST.node));
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
2015-02-12 12:00:55 +01:00
|
|
|
public void perform() throws MassiveException
|
2015-01-13 13:50:38 +01:00
|
|
|
{
|
|
|
|
// Args
|
2015-05-13 23:00:53 +02:00
|
|
|
int page = this.readArg();
|
2015-01-13 13:50:38 +01:00
|
|
|
|
2015-05-06 17:04:35 +02:00
|
|
|
Faction faction = this.readArg(msenderFaction);
|
2015-01-13 13:50:38 +01:00
|
|
|
|
|
|
|
if ( faction != msenderFaction && ! Perm.INVITE_LIST_OTHER.has(sender, true)) return;
|
|
|
|
|
|
|
|
// MPerm
|
|
|
|
if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return;
|
|
|
|
|
2015-09-05 13:44:24 +02:00
|
|
|
// Pager Create
|
2015-01-13 13:50:38 +01:00
|
|
|
final List<MPlayer> mplayers = faction.getInvitedMPlayers();
|
2015-09-05 13:44:24 +02:00
|
|
|
final Pager<MPlayer> pager = new Pager<MPlayer>(this, "Invited Players List", page, mplayers, new Stringifier<MPlayer>(){
|
2015-02-17 10:40:15 +01:00
|
|
|
public String toString(MPlayer target, int index)
|
2015-01-13 13:50:38 +01:00
|
|
|
{
|
|
|
|
// TODO: Madus would like to implement this in MPlayer
|
|
|
|
String targetName = target.getDisplayName(msender);
|
|
|
|
String isAre = target == msender ? "are" : "is";
|
|
|
|
Rel targetRank = target.getRole();
|
|
|
|
Faction targetFaction = target.getFaction();
|
|
|
|
String theAan = targetRank == Rel.LEADER ? "the" : Txt.aan(targetRank.name());
|
|
|
|
String rankName = Txt.getNicedEnum(targetRank).toLowerCase();
|
|
|
|
String ofIn = targetRank == Rel.LEADER ? "of" : "in";
|
|
|
|
String factionName = targetFaction.describeTo(msender, true);
|
|
|
|
if (targetFaction == msenderFaction)
|
|
|
|
{
|
|
|
|
factionName = factionName.toLowerCase();
|
|
|
|
}
|
|
|
|
return Txt.parse("%s <i>%s %s <h>%s <i>%s %s<i>.", targetName, isAre, theAan, rankName, ofIn, factionName);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-09-05 13:44:24 +02:00
|
|
|
// Pager Message
|
|
|
|
pager.message();
|
2015-01-13 13:50:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|