private function handle(TaskHandler $handler) { if ($handler->isDelayed()) { $nextRun = $this->currentTick + $handler->getDelay(); } else { $nextRun = $this->currentTick; } $handler->setNextRun($nextRun); $this->tasks[$handler->getTaskId()] = $handler; $this->queue->insert($handler, $nextRun); return $handler; }
public function setUpdateInterval($interval) { $this->handler->cancel(); $this->handler = $this->getOwner()->getServer()->getScheduler()->scheduleRepeatingTask($this, $interval); }
/** * @param TaskHandler $task * @param $period * * @return TimingsHandler */ public static function getPluginTaskTimings(TaskHandler $task, $period) { $ftask = $task->getTask(); if ($ftask instanceof PluginTask and $ftask->getOwner() !== null) { $plugin = $ftask->getOwner()->getDescription()->getFullName(); } elseif ($task->timingName !== null) { $plugin = "Scheduler"; } else { $plugin = "Unknown"; } $taskname = $task->getTaskName(); $name = "Task: " . $plugin . " Runnable: " . $taskname; if ($period > 0) { $name .= "(interval:" . $period . ")"; } else { $name .= "(Single)"; } if (!isset(self::$pluginTaskTimingMap[$name])) { self::$pluginTaskTimingMap[$name] = new TimingsHandler($name, self::$schedulerSyncTimer); } return self::$pluginTaskTimingMap[$name]; }
public function teleport(Vector3 $pos, $yaw = null, $pitch = null) { if (parent::teleport($pos, $yaw, $pitch)) { $this->airTicks = 300; $this->fallDistance = 0; $this->orderChunks(); $this->chunkLoadTask->setNextRun(0); $this->forceMovement = $pos; $pk = new MovePlayerPacket(); $pk->eid = 0; $pk->x = $this->x; $pk->y = $this->y + $this->getEyeHeight(); $pk->z = $this->z; $pk->bodyYaw = $this->yaw; $pk->pitch = $this->pitch; $pk->yaw = $this->yaw; $pk->teleport = true; $this->directDataPacket($pk); } }