Hey i've a big bug with my onJoin function. PHP: <?phpnamespace Asparanc\EconomyMaster;use pocketmine\plugin\PluginBase;use pocketmine\Player;use pocketmine\Server;use pocketmine\permission\Permission;use pocketmine\event\Listener;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\utils\TextFormat;use Asparanc\EconomyMaster\EcoAPI;class Register implements Listener{public function __construct(EcoAPI $plugin){ $this->plugin = $plugin; }public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); if(!EcoAPI::getInstance()->isRegistered($player->getName())){ $this->data = $this->getDataFolder(); $data = new Config($this->data . "players/" . strtolower($player->getName() . ".yml"), Config::YAML); $data->set("money", 0); $date->set("bank", 0); $data->save(); $this->plugin->getLogger()->notice("New player : ".$player->getName()); }else{ $this->plugin->getLogger()->notice("aaaa");}}} PHP: <?phpnamespace Asparanc\EconomyMaster;use pocketmine\plugin\PluginBase;use pocketmine\command\CommandExecutor;use pocketmine\utils\Config;use pocketmine\utils\TextFormat;use pocketmine\command\CommandSender;use pocketmine\Player;use Asparanc\EconomyMaster\Register;class EcoAPI extends PluginBase{public $config;public $data;private static $object = null; public static function getInstance(){ return self::$object; } public function onLoad(){ if(!self::$object instanceof EconomyMaster){ self::$object = $this; } $this->data = $this->getDataFolder();} public function onEnable(){ @mkdir($this->getDataFolder()); @mkdir($this->getDataFolder() . "players/"); @mkdir($this->getDataFolder() . "areas/"); @mkdir($this->getDataFolder() . "casinos/"); @mkdir($this->getDataFolder() . "clouds/"); @mkdir($this->getDataFolder() . "lands/"); @mkdir($this->getDataFolder() . "npcs/"); @mkdir($this->getDataFolder() . "pjobs/"); @mkdir($this->getDataFolder() . "pshops/"); @mkdir($this->getDataFolder() . "signs/"); @mkdir($this->getDataFolder() . "coporates/"); $this->data = $this->getDataFolder(); $this->config = $this->getConfig()->getAll(); $this->playerfolder = $this->getDataFolder() . "players/";}public function getSymbol(){ $this->config = new Config($this->data . "config.yml", Config::YAML); return $this->config->get('symbol');}public function isRegistered($player){ return file_exists($this->playerfolder.strtolower($player.".yml"));}} I don't understand why it don't work, the server just do anything, same as the code doesn't exist...
Because you don't register the event in the "onEnable()" function, try to add the following line: PHP: $this->getServer()->getPluginManager()->registerEvents($this, $this);
Yes Ooops, try this: PHP: $this->getServer()->getPluginManager()->registerEvents(new Register($this), $this);
No, please look at other plugins that use this kind of function, if you can't get it working, register it in the main class
PHP: /** * @param PlayerJoinEvent * * @priority MONITOR * @ignoreCancelled true */ Maybe add that And also, what is exactly the bug?