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

62 lines
1.7 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import java.util.ArrayList;
import java.util.List;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.arg.ARMPerm;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPerm;
2015-02-12 12:00:55 +01:00
import com.massivecraft.massivecore.MassiveException;
2015-05-06 17:04:35 +02:00
import com.massivecraft.massivecore.cmd.arg.ARAll;
import com.massivecraft.massivecore.cmd.arg.ARSet;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsPermShow extends FactionsCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsPermShow()
{
// Aliases
this.addAliases("s", "show");
// Args
2015-05-06 17:04:35 +02:00
this.addArg(ARFaction.get(), "faction", "you");
this.addArg(ARAll.get(ARSet.get(ARMPerm.get(), false)), "perms", "all", true);
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.PERM_SHOW.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
2015-02-12 12:00:55 +01:00
public void perform() throws MassiveException
{
// Arg: Faction
2015-05-06 17:04:35 +02:00
Faction faction = this.readArg(msenderFaction);
List<MPerm> mperms = this.readArg(MPerm.getAll());
// Create messages
List<String> messages = new ArrayList<String>();
messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
messages.add(MPerm.getStateHeaders());
2015-05-06 17:04:35 +02:00
for (MPerm mperm : mperms)
{
messages.add(Txt.parse(mperm.getStateInfo(faction.getPermitted(mperm), true)));
}
// Send messages
sendMessage(messages);
}
}