Factions3/src/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java
2015-05-06 21:44:59 +02:00

54 lines
1.4 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
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.MassiveException;
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.addArg(ARMPlayer.getAny(), "player");
this.addArg(ARBoolean.get(), "yes/no", "toggle");
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_PLAYER.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void innerPerform() throws MassiveException
{
// Args
MPlayer mplayer = this.readArg();
boolean newValue = this.readArg(!ta.isPlayerIdGranted(mplayer.getId()));
// MPerm
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
// Apply
ta = ta.withPlayerId(mplayer.getId(), newValue);
BoardColl.get().setTerritoryAccessAt(chunk, ta);
// Inform
this.sendAccessInfo();
}
}