Completed
Push — dev ( 9673a2...845ef5 )
by
unknown
02:30
created

JoinLeaveMessages::onPlayerInfoChanged()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
1
<?php
2
3
namespace eXpansion\Bundle\JoinLeaveMessages\Plugins;
4
5
use eXpansion\Framework\Core\DataProviders\Listener\PlayerDataListenerInterface;
6
use eXpansion\Framework\Core\Helpers\ChatNotification;
7
use eXpansion\Framework\Core\Services\Console;
8
use eXpansion\Framework\Core\Storage\Data\Player;
9
use Maniaplanet\DedicatedServer\Connection;
10
11
class JoinLeaveMessages implements PlayerDataListenerInterface
12
{
13
    /** @var Connection */
14
    protected $connection;
15
    /** @var Console */
16
    protected $console;
17
    /** @var bool $enabled is output enabled */
18
    private $enabled = true;
19
    /**
20
     * @var ChatNotification $chat
21
     */
22
    protected $chat;
23
24
    /**
25
     * JoinLeaveMessages constructor.
26
     *
27
     * @param Connection $connection
28
     * @param Console $console
29
     */
30
    public function __construct(Connection $connection, Console $console, ChatNotification $chatNotification)
31
    {
32
        $this->connection = $connection;
33
        $this->console = $console;
34
        $this->chat = $chatNotification;
35
    }
36
37
//#region Callbacks
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function onRun()
43
    {
44
        // @todo make this callback work!
45
        $this->enabled = true;
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    public function onPlayerConnect(Player $player)
52
    {
53
        $this->chat->sendMessage(
54
            "expansion_join_leave_messages.connect",
55
            null,
56
            ["%nickname%" => $player->getNickName(),
57
                "%login%" => $player->getLogin()
58
            ]);
59
    }
60
61
    /**
62
     * @inheritdoc
63
     */
64
    public function onPlayerDisconnect(Player $player, $disconnectionReason)
65
    {
66
        $this->chat->sendMessage(
67
            "expansion_join_leave_messages.disconnect",
68
            null,
69
            ["%nickname%" => $player->getNickName(),
70
             "%login%" => $player->getLogin()
71
             ]);
72
    }
73
74
    /**
75
     * @inheritdoc
76
     */
77
    public function onPlayerInfoChanged(Player $oldPlayer, Player $player)
78
    {
79
    }
80
81
    /**
82
     * @inheritdoc
83
     */
84
    public function onPlayerAlliesChanged(Player $oldPlayer, Player $player)
85
    {
86
    }
87
//#endregion
88
89
}
90