Factions/src/com/massivecraft/factions/cmd/CmdFactionsFlagShow.java

61 lines
1.6 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import java.util.List;
import com.massivecraft.factions.cmd.type.TypeFaction;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MFlag;
2015-02-12 12:00:55 +01:00
import com.massivecraft.massivecore.MassiveException;
2017-03-17 10:09:57 +01:00
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.command.Parameter;
import com.massivecraft.massivecore.pager.Pager;
import com.massivecraft.massivecore.pager.Stringifier;
public class CmdFactionsFlagShow extends FactionsCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsFlagShow()
{
// Parameters
this.addParameter(TypeFaction.get(), "faction", "you");
2017-03-17 10:09:57 +01:00
this.addParameter(Parameter.getPage());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
2015-02-12 12:00:55 +01:00
public void perform() throws MassiveException
{
2017-03-17 10:09:57 +01:00
// Parameters
final Faction faction = this.readArg(msenderFaction);
int page = this.readArg();
2017-03-17 10:09:57 +01:00
// Pager create
String title = "Flags for " + faction.describeTo(msender);
Pager<MFlag> pager = new Pager<>(this, title, page, MFlag.getAll(), new Stringifier<MFlag>()
{
2017-03-17 10:09:57 +01:00
@Override
public String toString(MFlag mflag, int index)
{
return mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true);
}
});
// Pager args
List<String> pagerArgs = new MassiveList<>(
faction.getId(),
String.valueOf(page)
);
pager.setArgs(pagerArgs);
// Pager message
pager.messageAsync();
}
}