22
33namespace Pterodactyl \Services \Servers ;
44
5+ use Illuminate \Support \Arr ;
56use Pterodactyl \Models \User ;
67use Pterodactyl \Models \Server ;
78use GuzzleHttp \Exception \RequestException ;
@@ -52,6 +53,11 @@ class StartupModificationService
5253 */
5354 private $ daemonServerRepository ;
5455
56+ /**
57+ * @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService
58+ */
59+ private $ structureService ;
60+
5561 /**
5662 * StartupModificationService constructor.
5763 *
@@ -60,6 +66,7 @@ class StartupModificationService
6066 * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $eggRepository
6167 * @param \Pterodactyl\Services\Servers\EnvironmentService $environmentService
6268 * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
69+ * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $structureService
6370 * @param \Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface $serverVariableRepository
6471 * @param \Pterodactyl\Services\Servers\VariableValidatorService $validatorService
6572 */
@@ -69,6 +76,7 @@ public function __construct(
6976 EggRepositoryInterface $ eggRepository ,
7077 EnvironmentService $ environmentService ,
7178 ServerRepositoryInterface $ repository ,
79+ ServerConfigurationStructureService $ structureService ,
7280 ServerVariableRepositoryInterface $ serverVariableRepository ,
7381 VariableValidatorService $ validatorService
7482 ) {
@@ -79,6 +87,7 @@ public function __construct(
7987 $ this ->serverVariableRepository = $ serverVariableRepository ;
8088 $ this ->validatorService = $ validatorService ;
8189 $ this ->daemonServerRepository = $ daemonServerRepository ;
90+ $ this ->structureService = $ structureService ;
8291 }
8392
8493 /**
@@ -110,19 +119,16 @@ public function handle(Server $server, array $data): Server
110119 });
111120 }
112121
113- $ daemonData = [];
114122 if ($ this ->isUserLevel (User::USER_LEVEL_ADMIN )) {
115- $ this ->updateAdministrativeSettings ($ data , $ server, $ daemonData );
123+ $ this ->updateAdministrativeSettings ($ data , $ server );
116124 }
117125
118- $ daemonData = array_merge_recursive ($ daemonData , [
119- 'build ' => [
120- 'env|overwrite ' => $ this ->environmentService ->handle ($ server ),
121- ],
122- ]);
126+ $ updateData = $ this ->structureService ->handle ($ server );
123127
124128 try {
125- $ this ->daemonServerRepository ->setServer ($ server )->update ($ daemonData );
129+ $ this ->daemonServerRepository ->setServer ($ server )->update (
130+ Arr::only ($ updateData , ['environment ' , 'invocation ' , 'service ' ])
131+ );
126132 } catch (RequestException $ exception ) {
127133 $ this ->connection ->rollBack ();
128134 throw new DaemonConnectionException ($ exception );
@@ -138,12 +144,11 @@ public function handle(Server $server, array $data): Server
138144 *
139145 * @param array $data
140146 * @param \Pterodactyl\Models\Server $server
141- * @param array $daemonData
142147 *
143148 * @throws \Pterodactyl\Exceptions\Model\DataValidationException
144149 * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
145150 */
146- private function updateAdministrativeSettings (array $ data , Server &$ server, array & $ daemonData )
151+ private function updateAdministrativeSettings (array $ data , Server &$ server )
147152 {
148153 if (
149154 is_digit (array_get ($ data , 'egg_id ' ))
@@ -163,13 +168,5 @@ private function updateAdministrativeSettings(array $data, Server &$server, arra
163168 'skip_scripts ' => array_get ($ data , 'skip_scripts ' ) ?? isset ($ data ['skip_scripts ' ]),
164169 'image ' => array_get ($ data , 'docker_image ' , $ server ->image ),
165170 ]);
166-
167- $ daemonData = array_merge ($ daemonData , [
168- 'build ' => ['image ' => $ server ->image ],
169- 'service ' => array_merge (
170- $ this ->repository ->getDaemonServiceData ($ server , true ),
171- ['skip_scripts ' => $ server ->skip_scripts ]
172- ),
173- ]);
174171 }
175172}
0 commit comments