99use Pterodactyl \Http \Controllers \Controller ;
1010use Pterodactyl \Repositories \Eloquent \ServerRepository ;
1111use Pterodactyl \Http \Requests \Api \Remote \InstallationDataRequest ;
12+ use Pterodactyl \Events \Server \Installed as ServerInstalled ;
13+ use Illuminate \Contracts \Events \Dispatcher as EventDispatcher ;
1214
1315class ServerInstallController extends Controller
1416{
@@ -17,12 +19,18 @@ class ServerInstallController extends Controller
1719 */
1820 private $ repository ;
1921
22+ /**
23+ * @var \Illuminate\Contracts\Events\Dispatcher
24+ */
25+ private $ eventDispatcher ;
26+
2027 /**
2128 * ServerInstallController constructor.
2229 */
23- public function __construct (ServerRepository $ repository )
30+ public function __construct (ServerRepository $ repository, EventDispatcher $ eventDispatcher )
2431 {
2532 $ this ->repository = $ repository ;
33+ $ this ->eventDispatcher = $ eventDispatcher ;
2634 }
2735
2836 /**
@@ -63,6 +71,11 @@ public function store(InstallationDataRequest $request, string $uuid)
6371
6472 $ this ->repository ->update ($ server ->id , ['status ' => $ status ], true , true );
6573
74+ // If the server successfully installed, fire installed event.
75+ if ($ status === null ) {
76+ $ this ->eventDispatcher ->dispatch (new ServerInstalled ($ server ));
77+ }
78+
6679 return new JsonResponse ([], Response::HTTP_NO_CONTENT );
6780 }
6881}
0 commit comments