How can I include multiple classes/files in my plugin. I have included the main in the constructor of my second file. However in the Main class, do I have to registerEvents? and if so, how?
To register events to another class PHP: public function onEnable() { $this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);} EventListener.php PHP: <?phpuse pocketmine\event\Listener;use pocketmine\event\player\PlayerJoinEvent;class EventListener implements Listener { private $plugin; public function __construct(Main $plugin) { $this->plugin = $plugin } public function onJoin(PlayerJoinEvent $event) { }}
Because you don't "include" another class in your plugin. Plugins are in object-oriented design and you don't and cannot do something like #include in C to run the code in another class. You have to understand that by creating another class in your plugin, you don't magically "inject" your code in another class into your main class. It's not like it automagically moves the functions into the main class such that they are also registered as event handlers (if you even qualitatively understand this)
I believe it was relevant to your question, who are you to tell someone what they can and can't say? SOFe was just trying to explain that you can't include classes in a plugin.