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

54 lines
1.5 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.BoardColl;
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;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAccessFaction()
{
2013-11-11 09:31:04 +01:00
// Aliases
this.addAliases("f", "faction");
2013-11-11 09:31:04 +01:00
// Args
this.addRequiredArg("faction");
this.addOptionalArg("yes/no", "toggle");
2013-11-11 09:31:04 +01:00
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_FACTION.node));
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
2015-02-12 12:00:55 +01:00
public void innerPerform() throws MassiveException
{
// Args
Faction faction = this.arg(0, ARFaction.get());
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId()));
// MPerm
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
// Apply
ta = ta.withFactionId(faction.getId(), newValue);
BoardColl.get().setTerritoryAccessAt(chunk, ta);
// Inform
this.sendAccessInfo();
}
2013-11-11 09:31:04 +01:00
}