Hi! I want to access the main because i want to create my config in the Eventlistener. But with this code: PHP: public function __construct(Main $plugin, $playerName){ $this->plugin = $plugin;//This is line 31 } And also with this code: Code: public function __construct(Main $plugin){ $this->plugin = $plugin;//This is line 31 } This failure comes: Code: [Server thread/CRITICAL]: ArgumentCountError: "Too few arguments to function Tim\SoupFFA\listener\EventListener::__construct(), 0 passed in C:\Users\beisp\Desktop\neuer server\plugins\SoupFFA\src\Tim\SoupFFA\Main.php on line 24 and exactly 2 expected" (EXCEPTION) in "plugins/SoupFFA/src/Tim/SoupFFA/listener/EventListener" at line 31 [17:13:19] [Server thread/CRITICAL]: #0 plugins/SoupFFA/src/Tim/SoupFFA/Main(24): Tim\SoupFFA\listener\EventListener->__construct() [17:13:19] [Server thread/CRITICAL]: #1 pmsrc/src/pocketmine/plugin/PluginBase(116): Tim\SoupFFA\Main->onEnable() [17:13:19] [Server thread/CRITICAL]: #2 pmsrc/src/pocketmine/plugin/PluginManager(552): pocketmine\plugin\PluginBase->setEnabled(boolean 1) [17:13:19] [Server thread/CRITICAL]: #3 pmsrc/src/pocketmine/Server(1786): pocketmine\plugin\PluginManager->enablePlugin(object Tim\SoupFFA\Main) [17:13:19] [Server thread/CRITICAL]: #4 pmsrc/src/pocketmine/Server(1772): pocketmine\Server->enablePlugin(object Tim\SoupFFA\Main) [17:13:19] [Server thread/CRITICAL]: #5 pmsrc/src/pocketmine/Server(1585): pocketmine\Server->enablePlugins(integer 1) [17:13:19] [Server thread/CRITICAL]: #6 pmsrc/src/pocketmine/PocketMine(291): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[36] C:\Users\beisp\Desktop\neuer server\, string[44] C:\Users\beisp\Desktop\neuer server\plugins\) [17:13:19] [Server thread/CRITICAL]: #7 pmsrc/src/pocketmine/PocketMine(321): pocketmine\server() [17:13:19] [Server thread/CRITICAL]: #8 pmsrc(11): require(string[91] phar://C:/Users/beisp/Desktop/neuer server/PocketMine-MP.phar/src/pocketmine/Poc) Anyone know what this mean?
Mhm weird. This is the line PHP: $this->getServer()->getPluginManager()->registerEvents(new EventListener(), $this);
exactly what the error says Code: Too few arguments to function you didn't pass any arguments to the EventListener's constructor, it needs one argument, which is the main instance to fix it, pass the main instance to EventListener PHP: $this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this); Edit: @Primus hah, too slow kek
Not at all! If you look at __contruct method signature, then you'll notice that 1st parameter is object of instance Main, however you pass exactly none.
Now my task isnt found anymore :/ Is there a way to bypass this problem? PHP: public function onEnable() { #Register Listener $this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this); #Register Database @mkdir($this->getDataFolder() . "Database/"); #Register Task $this->getScheduler()->scheduleRepeatingTask(new ScoreboardTask($this), 20); }
This is the location: And this is the error: PHP: [Server thread/CRITICAL]: Error: "Class 'Tim\SoupFFA\ScoreboardTask' not found" (EXCEPTION) in "plugins/SoupFFA/src/Tim/SoupFFA/Main" at line 30[10:48:34] [Server thread/CRITICAL]: #0 pmsrc/src/pocketmine/plugin/PluginBase(116): Tim\SoupFFA\Main->onEnable()[10:48:34] [Server thread/CRITICAL]: #1 pmsrc/src/pocketmine/plugin/PluginManager(552): pocketmine\plugin\PluginBase->setEnabled(boolean 1)[10:48:34] [Server thread/CRITICAL]: #2 pmsrc/src/pocketmine/Server(1786): pocketmine\plugin\PluginManager->enablePlugin(object Tim\SoupFFA\Main)[10:48:34] [Server thread/CRITICAL]: #3 pmsrc/src/pocketmine/Server(1772): pocketmine\Server->enablePlugin(object Tim\SoupFFA\Main)[10:48:34] [Server thread/CRITICAL]: #4 pmsrc/src/pocketmine/Server(1585): pocketmine\Server->enablePlugins(integer 1)[10:48:34] [Server thread/CRITICAL]: #5 pmsrc/src/pocketmine/PocketMine(291): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[36] C:\Users\beisp\Desktop\neuer server\, string[44] C:\Users\beisp\Desktop\neuer server\plugins\)[10:48:34] [Server thread/CRITICAL]: #6 pmsrc/src/pocketmine/PocketMine(321): pocketmine\server()[10:48:34] [Server thread/CRITICAL]: #7 pmsrc(11): require(string[91] phar://C:/Users/beisp/Desktop/neuer server/PocketMine-MP.phar/src/pocketmine/Poc)
That, or remove this if you have it: PHP: use Tim\SoupFFA\ScoreboardTask; Considering it’s in the same directory (with the same namespace) it unnecessary to include it.