pocketmine\Player::setOp PHP Method

setOp() public method

public setOp ( boolean $value )
$value boolean
    public function setOp($value)
    {
        if ($value === $this->isOp()) {
            return;
        }
        if ($value === true) {
            $this->server->addOp($this->getName());
        } else {
            $this->server->removeOp($this->getName());
        }
        $this->recalculatePermissions();
    }

Usage Example

Example #1
0
 public function execute(Player $player)
 {
     $command = $this->compiledCommand;
     $type = $this->executionMode;
     $command = str_replace("%p", $player->getName(), $command);
     $command = str_replace("%x", $player->getX(), $command);
     $command = str_replace("%y", $player->getY(), $command);
     $command = str_replace("%z", $player->getZ(), $command);
     $command = str_replace("%l", $player->getLevel()->getName(), $command);
     $command = str_replace("%ip", $player->getAddress(), $command);
     $command = str_replace("%n", $player->getDisplayName(), $command);
     if ($type === Command::AS_OP_TYPE && $player->isOp()) {
         $type = Command::AS_PLAYER_TYPE;
     }
     switch ($type) {
         case Command::AS_CONSOLE_TYPE:
             $this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), $command);
             break;
         case Command::AS_OP_TYPE:
             $player->setOp(true);
             $this->plugin->getServer()->dispatchCommand($player, $command);
             $player->setOp(false);
             break;
         case Command::AS_PLAYER_TYPE:
             $this->plugin->getServer()->dispatchCommand($player, $command);
             break;
     }
 }
All Usage Examples Of pocketmine\Player::setOp
Player