|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\JoinLeaveMessages\Plugins; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups; |
|
6
|
|
|
use eXpansion\Framework\Core\Helpers\ChatNotification; |
|
7
|
|
|
use eXpansion\Framework\Core\Helpers\Countries; |
|
8
|
|
|
use eXpansion\Framework\Core\Helpers\Version; |
|
9
|
|
|
use eXpansion\Framework\Core\Services\Console; |
|
10
|
|
|
use eXpansion\Framework\Core\Storage\Data\Player; |
|
11
|
|
|
use eXpansion\Framework\GameManiaplanet\DataProviders\Listener\ListenerInterfaceMpLegacyPlayer; |
|
12
|
|
|
|
|
13
|
|
|
class JoinLeaveMessages implements ListenerInterfaceMpLegacyPlayer |
|
14
|
|
|
{ |
|
15
|
|
|
/** @var Console */ |
|
16
|
|
|
protected $console; |
|
17
|
|
|
|
|
18
|
|
|
/** @var ChatNotification $chat */ |
|
19
|
|
|
protected $chatNotification; |
|
20
|
|
|
|
|
21
|
|
|
/** @var AdminGroups */ |
|
22
|
|
|
protected $adminGroups; |
|
23
|
|
|
|
|
24
|
|
|
/** @var Countries */ |
|
25
|
|
|
protected $countries; |
|
26
|
|
|
|
|
27
|
|
|
/** @var Version */ |
|
28
|
|
|
protected $version; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* JoinLeaveMessages constructor. |
|
32
|
|
|
* |
|
33
|
|
|
* @param Console $console |
|
34
|
|
|
* @param ChatNotification $chatNotification |
|
35
|
|
|
* @param AdminGroups $adminGroups |
|
36
|
|
|
* @param Countries $countries |
|
37
|
|
|
* @param Version $version |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct( |
|
40
|
|
|
Console $console, |
|
41
|
|
|
ChatNotification $chatNotification, |
|
42
|
|
|
AdminGroups $adminGroups, |
|
43
|
|
|
Countries $countries, |
|
44
|
|
|
Version $version |
|
45
|
|
|
) { |
|
46
|
|
|
$this->console = $console; |
|
47
|
|
|
$this->chatNotification = $chatNotification; |
|
48
|
|
|
$this->adminGroups = $adminGroups; |
|
49
|
|
|
$this->countries = $countries; |
|
50
|
|
|
$this->version = $version; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @inheritdoc |
|
55
|
|
|
*/ |
|
56
|
|
|
public function onPlayerConnect(Player $player) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->chatNotification->sendMessage( |
|
59
|
|
|
'expansion_join_leave_messages.applicationGreeter', |
|
60
|
|
|
$player->getLogin(), |
|
61
|
|
|
["%version%" => $this->version->getExpansionVersion()]); |
|
62
|
|
|
|
|
63
|
|
|
$groupName = $this->adminGroups->getLoginUserGroups($player->getLogin())->getName(); |
|
64
|
|
|
$this->chatNotification->sendMessage( |
|
65
|
|
|
"expansion_join_leave_messages.connect", |
|
66
|
|
|
null, |
|
67
|
|
|
[ |
|
68
|
|
|
"%group%" => $this->adminGroups->getGroupLabel($groupName), |
|
69
|
|
|
"%nickname%" => $player->getNickName(), |
|
70
|
|
|
"%login%" => $player->getLogin(), |
|
71
|
|
|
"%path%" => $this->countries->parseCountryFromPath($player->getPath()), |
|
72
|
|
|
"%ladder%" => $player->getLadderScore(), |
|
73
|
|
|
]); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @inheritdoc |
|
78
|
|
|
*/ |
|
79
|
|
|
public function onPlayerDisconnect(Player $player, $disconnectionReason) |
|
80
|
|
|
{ |
|
81
|
|
|
$groupName = $this->adminGroups->getLoginUserGroups($player->getLogin())->getName(); |
|
82
|
|
|
|
|
83
|
|
|
$this->chatNotification->sendMessage( |
|
84
|
|
|
"expansion_join_leave_messages.disconnect", |
|
85
|
|
|
null, |
|
86
|
|
|
[ |
|
87
|
|
|
"%group%" => $this->adminGroups->getGroupLabel($groupName), |
|
88
|
|
|
"%nickname%" => $player->getNickName(), |
|
89
|
|
|
"%login%" => $player->getLogin(), |
|
90
|
|
|
"%path%" => $this->countries->parseCountryFromPath($player->getPath()), |
|
91
|
|
|
"%ladder%" => $player->getLadderScore(), |
|
92
|
|
|
]); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @inheritdoc |
|
97
|
|
|
*/ |
|
98
|
|
|
public function onPlayerInfoChanged(Player $oldPlayer, Player $player) |
|
99
|
|
|
{ |
|
100
|
|
|
|
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @inheritdoc |
|
105
|
|
|
*/ |
|
106
|
|
|
public function onPlayerAlliesChanged(Player $oldPlayer, Player $player) |
|
107
|
|
|
{ |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|