2013-04-29 10:23:39 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPerm;
|
|
|
|
import com.massivecraft.factions.Perm;
|
|
|
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
2014-09-17 13:17:33 +02:00
|
|
|
import com.massivecraft.factions.entity.BoardColl;
|
2013-04-29 10:23:39 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
|
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
2013-04-29 10:23:39 +02:00
|
|
|
|
|
|
|
public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
|
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-29 10:23:39 +02:00
|
|
|
public CmdFactionsAccessFaction()
|
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// Aliases
|
2013-04-29 10:23:39 +02:00
|
|
|
this.addAliases("f", "faction");
|
|
|
|
|
2013-11-11 09:31:04 +01:00
|
|
|
// Args
|
2013-04-29 10:23:39 +02:00
|
|
|
this.addRequiredArg("faction");
|
|
|
|
this.addOptionalArg("yes/no", "toggle");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Requirements
|
2013-04-29 10:23:39 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_FACTION.node));
|
|
|
|
}
|
|
|
|
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-29 10:23:39 +02:00
|
|
|
@Override
|
|
|
|
public void innerPerform()
|
|
|
|
{
|
|
|
|
// Args
|
2014-09-17 13:17:33 +02:00
|
|
|
Faction faction = this.arg(0, ARFaction.get());
|
2013-04-29 10:23:39 +02:00
|
|
|
if (faction == null) return;
|
|
|
|
|
|
|
|
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId()));
|
|
|
|
if (newValue == null) return;
|
|
|
|
|
|
|
|
// FPerm
|
2013-04-29 10:26:15 +02:00
|
|
|
if (!FPerm.ACCESS.has(usender, hostFaction, true)) return;
|
2013-04-29 10:23:39 +02:00
|
|
|
|
|
|
|
// Apply
|
|
|
|
ta = ta.withFactionId(faction.getId(), newValue);
|
2014-09-17 13:17:33 +02:00
|
|
|
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
2013-04-29 10:23:39 +02:00
|
|
|
|
|
|
|
// Inform
|
|
|
|
this.sendAccessInfo();
|
|
|
|
}
|
2013-11-11 09:31:04 +01:00
|
|
|
|
2013-04-29 10:23:39 +02:00
|
|
|
}
|