PHP: // Your file$this->config= new Config($this->getDataFolder() . "config.yml" , Config::YAML);$this->config->get("message"); Code: --- # Config file message: "This is the message that it will send" Is this what you want?
PHP: public function onJoin(PlayerJoinEvent $event){ $event->setJoinMessage($this->getConfig()->get("join"));} PHP: public function onKick(PlayerKickEvent $event){ $event->setQuitMessage($this->getConfig()->get("leave"));} also remember to register events
Now I have this problem: [19:48:24] [Server thread/CRITICAL]: ErrorException: "Undefined variable: config" (EXCEPTION) in "plugins/JoinLeave-1.1.1/src/JoinLeave/Main" at line 27 [19:48:24] [Server thread/CRITICAL]: #0 plugins/JoinLeave-1.1.1/src/JoinLeave/Main(27): pocketmine\utils\Utils::errorExceptionHandler(integer 8, string[26] Undefined variable: config, string[90] C:\Users\arese\Desktop\MineWars Test Server\plugins\JoinLeave-1.1.1\src\JoinLeav, integer 27, array[0]) [19:48:24] [Server thread/CRITICAL]: #1 pmsrc/src/pocketmine/plugin/PluginBase(116): JoinLeave\Main->onEnable() [19:48:24] [Server thread/CRITICAL]: #2 pmsrc/src/pocketmine/plugin/PluginManager(552): pocketmine\plugin\PluginBase->setEnabled(boolean 1) [19:48:24] [Server thread/CRITICAL]: #3 pmsrc/src/pocketmine/Server(1785): pocketmine\plugin\PluginManager->enablePlugin(object JoinLeave\Main) [19:48:24] [Server thread/CRITICAL]: #4 pmsrc/src/pocketmine/Server(1771): pocketmine\Server->enablePlugin(object JoinLeave\Main) [19:48:24] [Server thread/CRITICAL]: #5 pmsrc/src/pocketmine/Server(1584): pocketmine\Server->enablePlugins(integer 1) [19:48:24] [Server thread/CRITICAL]: #6 pmsrc/src/pocketmine/PocketMine(291): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[44] C:\Users\arese\Desktop\MineWars Test Server\, string[52] C:\Users\arese\Desktop\MineWars Test Server\plugins\) [19:48:24] [Server thread/CRITICAL]: #7 pmsrc/src/pocketmine/PocketMine(321): pocketmine\server() [19:48:24] [Server thread/CRITICAL]: #8 pmsrc(11): require(string[99] phar://C:/Users/arese/Desktop/MineWars Test Server/PocketMine-MP.phar/src/pocket) I used this tutorial: https://forums.pmmp.io/threads/using-configs.1975/
PHP: /** @var string[] */ private $config; public function onEnable() : void { $this->config = $this->getConfig()->getAll(); // ?????????????????????????????????????????????????????????? }} + @mkdir($this->getDataFolder()); isn't necessary !