Factions/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java
2014-09-17 13:29:58 +02:00

56 lines
1.4 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARMPlayer;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAccessPlayer()
{
// Aliases
this.addAliases("p", "player");
// Args
this.addRequiredArg("player");
this.addOptionalArg("yes/no", "toggle");
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_PLAYER.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void innerPerform()
{
// Args
MPlayer mplayer = this.arg(0, ARMPlayer.getAny());
if (mplayer == null) return;
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(mplayer.getId()));
if (newValue == null) return;
// FPerm
if (!FPerm.ACCESS.has(usender, hostFaction, true)) return;
// Apply
ta = ta.withPlayerId(mplayer.getId(), newValue);
BoardColl.get().setTerritoryAccessAt(chunk, ta);
// Inform
this.sendAccessInfo();
}
}