OK , I've got an interesting situation. I'm trying to make a simple chat prefix plugin but my events are not registering correctly. Here's my code for the main class: Code: namespace StevieBlock\Chat; use pocketmine\plugin\PluginBase; class Main extends PluginBase { public $config; public function onEnable() { $this->getServer()->getPluginManager()->registerEvent(new Listeners($this), $this); @mkdir($this->getDataFolder()); $this->saveDefaultConfig(); $this->$config = $this->getConfig(); } } Here's my code for my listener class: Code: namespace StevieBlock\Chat; use pocketmine\event\Listener; use pocketmine\event\player\PlayerChatEvent; use StevieBlock\Chat\Main; class Listeners implements Listener{ public $main; public $config; public function __construct(Main $main) { $this->main = $main; $this->config = $main->getConfig(); } public function onPlayerChat(PlayerChatEvent $event) { $prefix = $config->get("players".$event->getPlayer()->getName()); $event->setMessage($prefix.$event->getMessage()); } } Here's the error: Code: [20:36:58] [Server thread/NOTICE]: RuntimeException: "Argument 2 passed to pocketmine\plugin\PluginManager::registerEvent() must implement interface pocketmine\event\Listener, instance of StevieBlock\Chat\Main given, called in C:\Users\Jacob\Desktop\PocketMine-MP\plugins\Chat--\src\StevieBlock\Chat\Main.php on line 16 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/plugin/PluginManager" at line 750 Thanks for all the support!
Just change: PHP: $this->getServer()->getPluginManager()->registerEvent(new Listeners($this), $this); to PHP: $this->getServer()->getPluginManager()->registerEvents($this, new Listeners($this)); Remember to look at the PocketMine source for more hints.
No, it should work. What I told you to fix should fix the problem you have, but not necessarily all the problems you have. And please learn PHP, the problem you encountered is only the first of many.
You access class properties by $this->property rather than $this->$property. $this->$property will make PHP find a variable called $property, convert it into a string and find a property with that name.
Codecademy has an OOP section, (I bought pro) it's just doesnt teach you to deal with api's. Most of my knowledge for OOP comes from Java.
You're not using or implementing Listener... PHP: use pocketmine\event\Listener; PHP: class Main extends PluginBase implements Listener {