Factions/src/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java
2017-03-25 00:47:01 +01:00

46 lines
1.3 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.type.TypeMPlayer;
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.command.type.primitive.TypeBooleanYes;
public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAccessPlayer()
{
// Parameters
this.addParameter(TypeMPlayer.get(), "player");
this.addParameter(TypeBooleanYes.get(), "yes/no", "toggle");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void innerPerform() throws MassiveException
{
// Args
MPlayer mplayer = this.readArg();
boolean newValue = this.readArg(!ta.isMPlayerGranted(mplayer));
// MPerm
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
// Apply
ta = ta.withPlayerId(mplayer.getId(), newValue);
BoardColl.get().setTerritoryAccessAt(chunk, ta);
// Inform
this.sendAccessInfo();
}
}