I just started trying to learn how to code plugins less than a day ago so have mercy on my knowledge lol I'm still learning but anyway. I tried to make a plugin that would say when a staff member joins the server using PurePerms groups. I thought I had it since I had no errors but it doesnt work and doesnt change the join message. Anyone mind helping me out? Spoiler: The code PHP: public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->perms = $this->getServer()->getPluginManager()->getPlugin("PurePerms"); $this->getLogger()->info("Finished loading!");} public function onJoin(PlayerJoinEvent $event) { $group = $this->perms->getUserDataMgr()->getGroup($event->getPlayer())->getName(); if($group == "Guest"){ $event->setJoinMessage("§7".$event->getPlayer()->getName() . "has joined the server!"); } if($group == "Mod"){ $event->setJoinMessage("§fServer §9Mod§b" . $event->getPlayer()->getName() . "§fhas joined the server!"); } if($group == "Admin"){ $event->setJoinMessage("§fServer §eAdmin§a" . $event->getPlayer()->getName() . "§fhas joined the server!"); } if($group == "Owner"){ $event->setJoinMessage("§fServer §4Owner§6" . $event->getPlayer()->getName() . "§fhas joined the server!"); } }} public function onQuit(PlayerQuitEvent $event) { $group = $this->perms->getUserDataMgr()->getGroup($event->getPlayer())->getName(); if($group == "Guest"){ $event->setQuitMessage("§7".$event->getPlayer()->getName() . "§fhas left the server!"); } if($group == "Mod"){ $event->setQuitMessage("§fServer §9Mod§b" . $event->getPlayer()->getName() . "§fhas left the server!"); } if($group == "Admin"){ $event->setQuitMessage("§fServer §eAdmin§a" . $event->getPlayer()->getName() . "§fhas left the server!"); } if($group == "Owner"){ $event->setQuitMessage("§fServer §4Owner§6" . $event->getPlayer()->getName() . "§fhas left the server!"); } } }}
I'm not sure how to do that tbh I've only just started doing this lol but if you could tell me how or direct me to where I could learn then that would be fine also
About learning PHP: i would suggest going through the PHP documentation, its really well written and a great starting point, PHP docs: https://www.php.net/docs.php About the pocketmine API: i personally would suggest going through its source code and see how stuff works, or go through other well-written plugins. About the problem you're having: Under this line: PHP: public function onJoin(PlayerJoinEvent $event) { $group = $this->perms->getUserDataMgr()->getGroup($event->getPlayer())->getName(); put PHP: var_dump($group); so in the end it should look like: PHP: public function onJoin(PlayerJoinEvent $event) { $group = $this->perms->getUserDataMgr()->getGroup($event->getPlayer())->getName(); var_dump($group); //other code... What var_dump does is basically "dump" the "var" aka the variable to the console, giving you its type, and value that way you can see if PHP: $group = $this->perms->getUserDataMgr()->getGroup($event->getPlayer())->getName(); returns the correct value you're looking for! var_dump() PHP docs: https://www.php.net/manual/en/function.var-dump.php
The code looks fine at first glance, so are you sure that your plugin loaded correctly? To check, when you type '/plugins' is it listed in green or red, or not there at all? Were there any errors on console during startup? Did you add PurePerms to the softdepend section of plugin.yml?