1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Help scheduler :/

Discussion in 'Facepalm' started by Lolipop78709, Jul 7, 2018.

  1. Lolipop78709

    Lolipop78709 Creeper

    Messages:
    5
    error in task help code...

    $player->getScheduler()->scheduleRepeatingTask($this, 2);

    ---------------------------------------------------------------------------------------------------------------------------------------------
    class BlockReplaceTask extends Task {

    /** @var Block $block */
    private $block;

    /** @var Player $player */
    private $player;

    /** @var Plugin $plugin */
    private $plugin;

    /**
    * @param Block $block
    * @param Player $player
    */
    public function __construct(Block $block, Player $player) {
    $player->getScheduler()->scheduleRepeatingTask($this, 2);
    $this->block = $block;
    $this->player = $player;
    }

    /**
    * Actions to execute when run
    *
    * @param int $currentTick
    *
    * @return void
    */
    public function onRun(int $currentTick) {
    $this->block->getLevel()->sendBlocks([$this->player], [$this->block]);
    unset($this->player, $this->block);
    }
    }
     
  2. Lolipop78709

    Lolipop78709 Creeper

    Messages:
    5
    exe

    public function sendRealBlock(Player $player) {
    $block = $this->getReplacementBlock();
    if($block instanceof Block) {
    new BlockReplaceTask($block, $player);
    }
    }
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.