So recently I figured out how to create custom events and nnow i would like to share it with everyone who doesnt know. First and foremost we must create the code where the event should be called, in this case we are going to call the event if the player runs the command "/event-test". PHP: public function onEventCommand(CommandSender $sender, Command $cmd, string $label, array $args){if($cmd->getName() == "event-test"){$sender->sendMessage("This is a test command for TestCommandEvent");}} Now we have the command "/event-test", after this we shall create the event. Make sure to use your own namepsace (Dont copy unlesss you know what your doing!). PHP: <?phpnamespace event\command;use pocketmine\event\plugin\PluginEvent;use pocketmine\event\Cancellable;class TestCommandEvent extends PluginEvent implements Cancellable{ private $player; private $cmd; public static $handlerList; public function __construct(Main $plugin, $player, $cmd){ parent::__construct($plugin); $this->player = $player; $this->cmd = $cmd } public function getPlayer(){ return $this->player; } public function getCommand(){ return $this->cmd; }} This will be our event that will be called when a player runs "/event-command". If you want the event to be able to be cancelled make sure to implement Cancellable, otherwise it cant be cancelled. The next step is to put callEvent() where we want TestCommandEvent to be called at, for this we are going to go back to the command. PHP: public function onEventCommand(CommandSender $sender, Command $cmd, string $label, array $args){if($cmd->getName() == "event-test"){$sender->sendMessage("This is a test command for TestCommandEvent");$this->getServer()->getPluginManager()->callEvent(new TestCommandEvent($this, $sender, $cmd->getName())); //This is where the command return true so the event should be called using this line of code.}} So now our event should be called when the player runs /event-test
This tutorial is too nanny and contains more irrelevant code than things that are actually relevant. Also does not explain about how events can be used to modify behaviour.