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

54 lines
1.5 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
2014-09-17 13:29:58 +02:00
import com.massivecraft.factions.cmd.arg.ARMPlayer;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAccessPlayer()
{
2013-11-11 09:31:04 +01:00
// Aliases
this.addAliases("p", "player");
2013-11-11 09:31:04 +01:00
// Args
this.addRequiredArg("player");
this.addOptionalArg("yes/no", "toggle");
2013-11-11 09:31:04 +01:00
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_PLAYER.node));
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void innerPerform() throws MassiveCommandException
{
// Args
2014-09-17 13:29:58 +02:00
MPlayer mplayer = this.arg(0, ARMPlayer.getAny());
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(mplayer.getId()));
// MPerm
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
// Apply
2014-09-17 13:29:58 +02:00
ta = ta.withPlayerId(mplayer.getId(), newValue);
BoardColl.get().setTerritoryAccessAt(chunk, ta);
// Inform
this.sendAccessInfo();
}
2013-11-11 09:31:04 +01:00
}