Hello, So I made an EventHandler.php file and started it like this: PHP: <?phpnamespace SkyWars;use pocketmine\Player;use pocketmine\level\Position;use pocketmine\level\Position\getLevel;use pocketmine\level\Level;use pocketmine\level\particle\FloatingTextParticle;use pocketmine\level\particle\Particle;use pocketmine\event\Listener;use pocketmine\event\player\PlayerChatEvent;use pocketmine\event\player\PlayerDeathEvent;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerPreLoginEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\math\Vector3;use pocketmine\utils\Config;use pocketmine\utils\TextFormat;use pocketmine\plugin\PluginTask;class EventHandler extends PluginTask implements Listener{ public function __construct(Main $plugin){ $this->plugin = $plugin; }//My events here (join, quit, die, chat, break, place) The problem is none of them are actually doing anything unless I move them into main file Any help appreciated, Thank you!!!
You must register events $this->getServer()->getPluginManager()->registerEvents($eventHandler, $this);
Why extend PluginTask? Btw in the main class' onEnable(), add PHP: $this->getServer()->getPluginManager()->registerEvents(new EventHandler($this), $this);
Now I get this error: Code: [Server thread/NOTICE]: InvalidArgumentException: "Argument 1 passed to SkyWars\EventHandler::__construct() must be an instance of SkyWars\Main, instance of SkyWars\SkyWars given, called in C:-\PocketMine-MP\plugins\SkyWars\src\SkyWars\SkyWars.php on line 143 and defined" (E_RECOVERABLE_ERROR) in "/SkyWars/src/SkyWars/EventHandler" at line 27
Instead of wasting all your time on writing bad code, why not take a look at these: php.net And: docs.pocketmine.net Try to look more at the first link.
None of those links teach me how to use multiple files, and codeacademy teaches you how to make websites.
php.net teaches everything. They are not "multiple files". They are "multiple classes", which can actually be in the same file.
It's "multiple classes", not "multiple files". If you don't believe having multiple classes in one file will work, look here.
It's called type hint if you put it next to __construct. If you are not trying to help, don't post. Apparently I've already pointed it out above.