Help console giving error PHP: public function refreshSigns(){ $pl = count($this->getServer()->getLevelByName("Hub")->getPlayers()); $lobby = $this->getServer()->getLevelByName("GDshop"); $t = $lobby->getTile(new Vector3(125, 44, 85)); $text = $t->getText(); if ($t instanceof Sign) { if ($text[0] == $this->prefix) { $t->setText($this->prefix, "§7" . $pl . "/14 §9]", $text[2], $text[3]); } }} ERROR Code: [11:39:29] [Server thread/CRITICAL]: Could not execute task GetDown\SignRefresher: Call to a member function getTile() on null [11:39:29] [Server thread/CRITICAL]: Error: "Call to a member function getTile() on null" (EXCEPTION) in "myzip:///GetDown.zip#GetDown/src/GetDown/Main" at line 484
Get the level on plugin enabling then if it's not loaded, throw an error or disable the plugin. PHP: if(!$level) { throw new \Exception("necessary level 'GDshop' was not loaded");} That's what Plugin::onEnable() is meant for, prepare your plugin!
Put this on onEnable() pls PHP: /*** Enable the plugin*/public function onEnable() { if(!$this->getServer()->isLevelLoaded("GDshop")) { $this->getServer()->loadLevel("GDshop"); }} and code should work
Of course I do. But you should still explain your code rather than just sending a random piece of code to someone who might not understand what it does and copy pastes it. Also your code is not ideal, and the isLevelLoaded check is not needed. PHP: /* I am assuming you are in a class that extends PluginBase */public function onEnable(){ //This function will be called by the server when your plugin is enabled. $levelName = "GDshop"; //The name of the level you want to use if($this->getServer()->loadLevel($levelName) === false){ //loadLevel returns false if level could not be loaded, and it ignore the request if the level is already loaded. $this->getLogger()->critical("I can't find my required level ".$levelName.". I will now disable myself"); //Output warning message using the pluginLogger $this->getServer()->getPluginManager()->disablePlugin($this); //Safely disables and unloads the plugin }} This disables the plugin if the level could not be found.