|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\AdminChat\ChatCommand; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups; |
|
6
|
|
|
use eXpansion\Framework\AdminGroups\Model\AbstractAdminChatCommand; |
|
7
|
|
|
use eXpansion\Framework\Core\Helpers\ChatNotification; |
|
8
|
|
|
use eXpansion\Framework\Core\Helpers\Time; |
|
9
|
|
|
use eXpansion\Framework\Core\Storage\MapStorage; |
|
10
|
|
|
use eXpansion\Framework\Core\Storage\PlayerStorage; |
|
11
|
|
|
use Maniaplanet\DedicatedServer\Connection; |
|
12
|
|
|
use Psr\Log\LoggerInterface; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class ReasonUserCommand |
|
17
|
|
|
* |
|
18
|
|
|
* @author Reaby |
|
19
|
|
|
* @package eXpansion\Bundle\AdminChat\ChatCommand |
|
20
|
|
|
*/ |
|
21
|
|
|
class AdminShuffleCommand extends AbstractAdminChatCommand |
|
22
|
|
|
{ |
|
23
|
|
|
/** @var ChatNotification */ |
|
24
|
|
|
private $chatNotification; |
|
25
|
|
|
|
|
26
|
|
|
/** @var PlayerStorage */ |
|
27
|
|
|
private $playerStorage; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var MapStorage |
|
31
|
|
|
*/ |
|
32
|
|
|
private $mapStorage; |
|
33
|
|
|
/** |
|
34
|
|
|
* @var Connection |
|
35
|
|
|
*/ |
|
36
|
|
|
private $connection; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* AdminCommand constructor. |
|
40
|
|
|
* |
|
41
|
|
|
* @param $command |
|
42
|
|
|
* @param string $permission |
|
43
|
|
|
* @param array $aliases |
|
44
|
|
|
* @param ChatNotification $functionName |
|
|
|
|
|
|
45
|
|
|
* @param AdminGroups $adminGroupsHelper |
|
46
|
|
|
* @param Connection $connection |
|
47
|
|
|
* @param ChatNotification $chatNotification |
|
48
|
|
|
* @param PlayerStorage $playerStorage |
|
49
|
|
|
* @param LoggerInterface $logger |
|
50
|
|
|
* @param Time $timeHelper |
|
|
|
|
|
|
51
|
|
|
* @param MapStorage $mapStorage |
|
52
|
|
|
*/ |
|
53
|
|
View Code Duplication |
public function __construct( |
|
|
|
|
|
|
54
|
|
|
$command, |
|
55
|
|
|
$permission, |
|
56
|
|
|
array $aliases = [], |
|
57
|
|
|
AdminGroups $adminGroupsHelper, |
|
58
|
|
|
ChatNotification $chatNotification, |
|
59
|
|
|
PlayerStorage $playerStorage, |
|
60
|
|
|
LoggerInterface $logger, |
|
61
|
|
|
Connection $connection, |
|
62
|
|
|
MapStorage $mapStorage |
|
63
|
|
|
) { |
|
64
|
|
|
parent::__construct( |
|
65
|
|
|
$command, |
|
66
|
|
|
$permission, |
|
67
|
|
|
$aliases = [], |
|
68
|
|
|
$adminGroupsHelper |
|
69
|
|
|
); |
|
70
|
|
|
|
|
71
|
|
|
$this->chatNotification = $chatNotification; |
|
72
|
|
|
$this->playerStorage = $playerStorage; |
|
73
|
|
|
$this->mapStorage = $mapStorage; |
|
74
|
|
|
$this->adminGroupsHelper = $adminGroupsHelper; |
|
75
|
|
|
$this->connection = $connection; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @inheritdoc |
|
80
|
|
|
*/ |
|
81
|
|
|
public function execute($login, InputInterface $input) |
|
82
|
|
|
{ |
|
83
|
|
|
$player = $this->playerStorage->getPlayerInfo($login)->getNickName(); |
|
|
|
|
|
|
84
|
|
|
$allMaps = []; |
|
85
|
|
|
foreach ($this->mapStorage->getMaps() as $map) { |
|
86
|
|
|
$maps[] = $map->fileName; |
|
|
|
|
|
|
87
|
|
|
$allMaps[] = $map->fileName; |
|
88
|
|
|
if (count($maps) > 250) { |
|
89
|
|
|
$this->connection->removeMapList($maps); |
|
|
|
|
|
|
90
|
|
|
$maps = []; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
// for remaining maps, which didn't fit to 200 |
|
94
|
|
|
$this->connection->removeMapList($maps); |
|
95
|
|
|
$this->connection->executeMulticall(); |
|
96
|
|
|
|
|
97
|
|
|
shuffle($allMaps); |
|
98
|
|
|
|
|
99
|
|
|
$maps = []; |
|
100
|
|
|
foreach ($allMaps as $x => $mapFile) { |
|
101
|
|
|
$maps[] = $mapFile; |
|
102
|
|
|
if (count($maps) > 250) { |
|
103
|
|
|
$this->connection->insertMapList($maps, true); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
// for remaining maps, which didn't fit to 200 |
|
107
|
|
|
$this->connection->insertMapList($maps, true); |
|
108
|
|
|
$this->connection->executeMulticall(); |
|
109
|
|
|
|
|
110
|
|
|
$level = $this->adminGroupsHelper->getLoginGroupLabel($login); |
|
111
|
|
|
$admin = $this->playerStorage->getPlayerInfo($login)->getNickName(); |
|
112
|
|
|
$this->chatNotification->sendMessage('expansion_admin_chat.shuffle.msg', null, |
|
113
|
|
|
["%adminLevel%" => $level, "%admin%" => $admin]); |
|
114
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.