1212use Webmozart \Assert \Assert ;
1313use Illuminate \Console \Command ;
1414use GuzzleHttp \Exception \RequestException ;
15- use Pterodactyl \Services \Servers \EnvironmentService ;
1615use Pterodactyl \Contracts \Repository \ServerRepositoryInterface ;
16+ use Pterodactyl \Services \Servers \ServerConfigurationStructureService ;
1717use Pterodactyl \Contracts \Repository \Daemon \ServerRepositoryInterface as DaemonServerRepositoryInterface ;
1818
1919class RebuildServerCommand extends Command
2020{
21+ /**
22+ * @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService
23+ */
24+ protected $ configurationStructureService ;
25+
2126 /**
2227 * @var \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface
2328 */
@@ -28,11 +33,6 @@ class RebuildServerCommand extends Command
2833 */
2934 protected $ description = 'Rebuild a single server, all servers on a node, or all servers on the panel. ' ;
3035
31- /**
32- * @var \Pterodactyl\Services\Servers\EnvironmentService
33- */
34- protected $ environmentService ;
35-
3636 /**
3737 * @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
3838 */
@@ -49,18 +49,18 @@ class RebuildServerCommand extends Command
4949 * RebuildServerCommand constructor.
5050 *
5151 * @param \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface $daemonRepository
52- * @param \Pterodactyl\Services\Servers\EnvironmentService $environmentService
52+ * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService
5353 * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
5454 */
5555 public function __construct (
5656 DaemonServerRepositoryInterface $ daemonRepository ,
57- EnvironmentService $ environmentService ,
57+ ServerConfigurationStructureService $ configurationStructureService ,
5858 ServerRepositoryInterface $ repository
5959 ) {
6060 parent ::__construct ();
6161
62+ $ this ->configurationStructureService = $ configurationStructureService ;
6263 $ this ->daemonRepository = $ daemonRepository ;
63- $ this ->environmentService = $ environmentService ;
6464 $ this ->repository = $ repository ;
6565 }
6666
@@ -74,19 +74,7 @@ public function handle()
7474
7575 $ servers ->each (function ($ server ) use ($ bar ) {
7676 $ bar ->clear ();
77- $ json = [
78- 'build ' => [
79- 'image ' => $ server ->image ,
80- 'env|overwrite ' => $ this ->environmentService ->process ($ server ),
81- ],
82- 'service ' => [
83- 'type ' => $ server ->option ->service ->folder ,
84- 'option ' => $ server ->option ->tag ,
85- 'pack ' => object_get ($ server , 'pack.uuid ' ),
86- 'skip_scripts ' => $ server ->skip_scripts ,
87- ],
88- 'rebuild ' => true ,
89- ];
77+ $ json = array_merge ($ this ->configurationStructureService ->handle ($ server ), ['rebuild ' => true ]);
9078
9179 try {
9280 $ this ->daemonRepository ->setNode ($ server ->node_id )->setAccessServer ($ server ->uuid )->update ($ json );
0 commit comments