i need the config below to go 5to the secound class for some reason it wont register public function onJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); $config = new Config($this->getDataFolder() . "$name.yml", Config::YAML); $soul = $config->get(strtolower($name)); // get players config if($soul == "") { //if no souls set to 0 $config->set(strtolower($name), 0); $config->save(); } } public function getPlayerConfig(string $name) : Config { $getPlayerConfig = new Config($this->getDataFolder()."$name.yml", Config::YAML); } other class public function __Constructor(Main $Plugin, playerConfig $getPlayerConfig){ $this->Main = $Plugin; $this->playerConfig = $getPlayerConfig; $this->playerConfig = $this->Main->getPlayerConfig(); } public function onBreak(BlockBreakEvent $event) { $player = $event->getPlayer(); $name = $player->getName(); $config = $this->getPlayerConfig(); $soul = $config->get(strtolower($name)); $player->sendMessage("2"); $config->set(strtolower($name), $soul + 1); $player->sendMessage("1"); $config->save(); error Error: "Call to undefined method CE\Items\Weapons\Sword\SoulGripperEnchant::getPlayerConfig()" (EXCEPTION) in "plugins/DCE/src/CE/Items/Weapons/Sword/SoulGripperEnchant" at line 28
You can't do PHP: $config = $this->getPlayerConfig(); , because getPlayerConfig() is not defined in that class. So you have to write PHP: $config = $this->Main->getPlayerConfig();
The method is defined in the class, it just doesn't return the config object that was constructed in it.
I know he forgot the return statement. However, I focused on the error which is at the end of the message. He has 2 classes, one main class and the second one. In the main class the method is defined, in the second class it is not.