1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Gameap\UseCases; |
4
|
|
|
|
5
|
|
|
use Gameap\Helpers\ServerHelper; |
|
|
|
|
6
|
|
|
use Gameap\Models\Server; |
7
|
|
|
use Gameap\Repositories\GameModRepository; |
8
|
|
|
use Gameap\Repositories\NodeRepository; |
9
|
|
|
use Gameap\Repositories\GdaemonTaskRepository; |
10
|
|
|
use Gameap\Repositories\ServerRepository; |
11
|
|
|
use Gameap\UseCases\Commands\CreateGameServerCommand; |
12
|
|
|
use Illuminate\Support\Str; |
13
|
|
|
|
14
|
|
|
class CreateGameServer |
15
|
|
|
{ |
16
|
|
|
public const DEFAULT_RCON_PASSWORD_LENGTH = 10; |
17
|
|
|
|
18
|
|
|
/** @var GdaemonTaskRepository */ |
19
|
|
|
protected $gdaemonTaskRepository; |
20
|
|
|
|
21
|
|
|
/** @var ServerRepository */ |
22
|
|
|
protected $serverRepository; |
23
|
|
|
|
24
|
|
|
/** @var NodeRepository */ |
25
|
|
|
protected $nodeRepository; |
26
|
|
|
|
27
|
|
|
/** @var GameModRepository */ |
28
|
|
|
protected $gameModRepository; |
29
|
|
|
|
30
|
|
|
public function __construct(GdaemonTaskRepository $gdaemonTaskRepository, ServerRepository $serverRepository, NodeRepository $nodeRepository, GameModRepository $gameModRepository) |
31
|
|
|
{ |
32
|
|
|
$this->gdaemonTaskRepository = $gdaemonTaskRepository; |
33
|
|
|
$this->serverRepository = $serverRepository; |
34
|
|
|
$this->nodeRepository = $nodeRepository; |
35
|
|
|
$this->gameModRepository = $gameModRepository; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function __invoke(CreateGameServerCommand $command) |
39
|
|
|
{ |
40
|
|
|
$server = new Server(); |
41
|
|
|
|
42
|
|
|
$server->uuid = Str::orderedUuid()->toString(); |
43
|
|
|
$server->uuid_short = Str::substr($server->uuid, 0, 8); |
44
|
|
|
$server->ds_id = $command->dsId; |
45
|
|
|
$server->name = $command->name; |
46
|
|
|
$server->game_id = $command->gameId; |
47
|
|
|
$server->game_mod_id = $command->gameModId; |
48
|
|
|
$server->server_ip = $command->serverIp; |
49
|
|
|
$server->server_port = $command->serverPort; |
50
|
|
|
$server->query_port = $command->queryPort; |
51
|
|
|
$server->rcon_port = $command->rconPort; |
52
|
|
|
$server->su_user = $command->suUser; |
53
|
|
|
|
54
|
|
|
$server->enabled = true; |
55
|
|
|
$server->blocked = false; |
56
|
|
|
|
57
|
|
|
if (empty($command->rcon)) { |
58
|
|
|
$server->rcon = Str::random(self::DEFAULT_RCON_PASSWORD_LENGTH); |
59
|
|
|
} else { |
60
|
|
|
$server->rcon = $command->rcon; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$node = $this->nodeRepository->findById($command->dsId); |
64
|
|
|
|
65
|
|
|
if (empty($command->startCommand)) { |
66
|
|
|
$gameMod = $this->gameModRepository->getById($command->gameModId); |
67
|
|
|
|
68
|
|
|
$server->start_command = |
69
|
|
|
$node->isLinux() |
70
|
|
|
? $gameMod->default_start_cmd_linux |
71
|
|
|
: $gameMod->default_start_cmd_windows; |
72
|
|
|
} else { |
73
|
|
|
$server->start_command = $command->startCommand; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if (empty($command->dir)) { |
77
|
|
|
$server->dir = 'servers/' . $server->uuid; |
78
|
|
|
} else { |
79
|
|
|
$server->dir = $command->dir; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
if ($command->install) { |
83
|
|
|
$server->installed = false; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$this->serverRepository->save($server); |
87
|
|
|
|
88
|
|
|
if ($command->install) { |
89
|
|
|
$this->gdaemonTaskRepository->addServerInstall($server); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths