PHP: class NPCTask extends Task{ public function __construct(Core $plugin) { $this->plugin = $plugin; $this->text = new FloatingTextParticle(new Vector3(783, 10.7, -1199), "", "§e"); } public function onRun($currentTick) { $level = $this->plugin->getServer()->getLevelByName("New spawn2"); foreach ($level->getEntities() as $ent){ if($ent->getId() == 2){ $ent->setNameTag("§l§6MicroBattle§r\n §7" . count($this->plugin->getOnline(1)) . " Playing"); } } }} error Code: Notice: Undefined variable: level in C:\Users\uzivatel\Desktop\Server\plugins\Core\src\Core\Core.php on line 1044 [14:31:55] [Server thread/CRITICAL]: Could not execute task Core\NPCTask: Call to a member function getEntities() on unknown [14:31:55] [Server thread/CRITICAL]: Error: "Call to a member function getEntities() on unknown" (EXCEPTION) in "/Core/src/Core/Core" at line 1044 DE]
Please include line numbers. And that code is some rather random snippet of a big plugin, so we can't magically know what your plugin does where and how. Please either post the full code, or large parts of it. We're not here to get thrown at with some random piece of code and an error message. Provide steps you've already taken (e.g. I've ensured that the level "New spawn2" exists, and the function returns a valid level object).
robske_110 is spot on, you need to start using git/github: you'll get help faster and it will make coding a LOT easier for you in the long run. Also, it's a very bad idea to use spaces in world names.