2015-01-09 22:36:12 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2015-05-07 22:13:48 +02:00
|
|
|
import java.util.Collection;
|
2015-01-09 22:36:12 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Perm;
|
2015-10-21 19:35:41 +02:00
|
|
|
import com.massivecraft.factions.cmd.type.TypeFaction;
|
|
|
|
import com.massivecraft.factions.cmd.type.TypeMPerm;
|
2015-01-09 22:36:12 +01:00
|
|
|
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-01-09 22:36:12 +01:00
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
2015-10-21 19:35:41 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.type.TypeAll;
|
|
|
|
import com.massivecraft.massivecore.cmd.type.TypeSet;
|
2015-01-09 22:36:12 +01:00
|
|
|
import com.massivecraft.massivecore.util.Txt;
|
|
|
|
|
|
|
|
public class CmdFactionsPermShow extends FactionsCommand
|
|
|
|
{
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
public CmdFactionsPermShow()
|
|
|
|
{
|
|
|
|
// Aliases
|
2015-10-21 21:18:00 +02:00
|
|
|
this.addAliases("show");
|
2015-01-09 22:36:12 +01:00
|
|
|
|
2015-10-21 19:35:41 +02:00
|
|
|
// Parameters
|
|
|
|
this.addParameter(TypeFaction.get(), "faction", "you");
|
|
|
|
this.addParameter(TypeAll.get(TypeSet.get(TypeMPerm.get(), false)), "perms", "all", true);
|
2015-01-09 22:36:12 +01:00
|
|
|
|
|
|
|
// Requirements
|
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.PERM_SHOW.node));
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
2015-02-12 12:00:55 +01:00
|
|
|
public void perform() throws MassiveException
|
2015-01-09 22:36:12 +01:00
|
|
|
{
|
|
|
|
// Arg: Faction
|
2015-05-06 17:04:35 +02:00
|
|
|
Faction faction = this.readArg(msenderFaction);
|
2015-05-07 22:13:48 +02:00
|
|
|
Collection<MPerm> mperms = this.readArg(MPerm.getAll());
|
2015-05-06 17:04:35 +02:00
|
|
|
|
2015-01-09 22:36:12 +01:00
|
|
|
// 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)
|
2015-01-09 22:36:12 +01:00
|
|
|
{
|
|
|
|
messages.add(Txt.parse(mperm.getStateInfo(faction.getPermitted(mperm), true)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send messages
|
2015-09-03 09:33:01 +02:00
|
|
|
message(messages);
|
2015-01-09 22:36:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|