public function dispatchEvent($n, $ev) { if ($this->listeners[$n]["command"] === null) { return; } $cmdline = $this->listeners[$n]["command"]; if (is_callable([$ev, "getPlayer"])) { $ctx = $ev->getPlayer(); } elseif (is_callable([$ev, "getEntity"]) && $ev->getEntity() instanceof Player) { $ctx = $ev->getEntity(); } else { $ctx = new ConsoleCommandSender(); } if (($rc = $this->owner->getModule("pmscripts")) !== null) { $rc->setEnv("event", $ev); Cmd::opexec($ctx, $cmdline); $rc->unsetEnv("event"); } else { Cmd::opexec($ctx, $cmdline); } }
public function dispatchEvent($n, $ev) { if ($this->listeners[$n]["command"] === null) { return; } if (is_callable([$ev, "getPlayer"])) { $ctx = $ev->getPlayer(); } elseif (is_callable([$ev, "getEntity"]) && $ev->getEntity() instanceof Player) { $ctx = $ev->getEntity(); } else { $ctx = new ConsoleCommandSender(); } Cmd::opexec($ctx, $cmdline); }