From 397df3bf710b9b1caf1b1c7ec37fef24e24bfe88 Mon Sep 17 00:00:00 2001 From: xcgc <74693042+xcgc@users.noreply.github.com> Date: Sat, 6 Mar 2021 15:52:24 +0800 Subject: [PATCH] Update ServerInstallController.php --- .../Remote/Servers/ServerInstallController.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php index 113b7c01e..fc3e04b72 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php @@ -9,6 +9,8 @@ use Illuminate\Http\JsonResponse; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Repositories\Eloquent\ServerRepository; use Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest; +use Pterodactyl\Events\Server\Installed as ServerInstalled; +use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; class ServerInstallController extends Controller { @@ -17,12 +19,18 @@ class ServerInstallController extends Controller */ private $repository; + /** + * @var \Illuminate\Contracts\Events\Dispatcher + */ + private $eventDispatcher; + /** * ServerInstallController constructor. */ - public function __construct(ServerRepository $repository) + public function __construct(ServerRepository $repository, EventDispatcher $eventDispatcher) { $this->repository = $repository; + $this->eventDispatcher = $eventDispatcher; } /** @@ -63,6 +71,11 @@ class ServerInstallController extends Controller $this->repository->update($server->id, ['status' => $status], true, true); + // If the server successfully installed, fire installed event. + if ($status === null) { + $this->eventDispatcher->dispatch(new ServerInstalled($server)); + } + return new JsonResponse([], Response::HTTP_NO_CONTENT); } }