private function addTask(Task $task, $delay, $period)
{
if ($task instanceof PluginTask) {
if (!$task->getOwner() instanceof Plugin) {
throw new PluginException("Invalid owner of PluginTask " . get_class($task));
} elseif (!$task->getOwner()->isEnabled()) {
throw new PluginException("Plugin '" . $task->getOwner()->getName() . "' attempted to register a task while disabled");
}
} elseif ($task instanceof CallbackTask and Server::getInstance()->getProperty("settings.deprecated-verbose", true)) {
$callable = $task->getCallable();
if (is_array($callable)) {
if (is_object($callable[0])) {
$taskName = "Callback#" . get_class($callable[0]) . "::" . $callable[1];
} else {
$taskName = "Callback#" . $callable[0] . "::" . $callable[1];
}
} else {
$taskName = "Callback#" . $callable;
}
//Server::getInstance()->getLogger()->warning("A plugin attempted to register a deprecated CallbackTask ($taskName)");
}
if ($delay <= 0) {
$delay = -1;
}
if ($period <= -1) {
$period = -1;
} elseif ($period < 1) {
$period = 1;
}
return $this->handle(new TaskHandler(get_class($task), $task, $this->nextId(), $delay, $period));
}