|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\VoteManager\Plugins\Votes; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Bundle\Maps\Services\JukeboxService; |
|
6
|
|
|
use eXpansion\Framework\Core\Helpers\ChatNotification; |
|
7
|
|
|
use eXpansion\Framework\Core\Storage\Data\Player; |
|
8
|
|
|
use eXpansion\Framework\Core\Storage\MapStorage; |
|
9
|
|
|
use eXpansion\Framework\Core\Storage\PlayerStorage; |
|
10
|
|
|
use Maniaplanet\DedicatedServer\Structures\Map; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class NextMapVote |
|
14
|
|
|
* |
|
15
|
|
|
* @author de Cramer Oliver<[email protected]> |
|
16
|
|
|
* @copyright 2017 eXpansion |
|
17
|
|
|
* @package eXpansion\Bundle\VoteManager\Plugins\Votes |
|
18
|
|
|
*/ |
|
19
|
|
|
class RestartMapVote extends AbstractVotePlugin |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var Map */ |
|
22
|
|
|
private $map; |
|
23
|
|
|
|
|
24
|
|
|
/** @var JukeboxService */ |
|
25
|
|
|
protected $jukebox; |
|
26
|
|
|
|
|
27
|
|
|
/** @var MapStorage */ |
|
28
|
|
|
protected $mapStorage; |
|
29
|
|
|
|
|
30
|
|
|
/** @var ChatNotification */ |
|
31
|
|
|
protected $chatNotification; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* RestartMapVote constructor. |
|
35
|
|
|
* |
|
36
|
|
|
* @param PlayerStorage $playerStorage |
|
37
|
|
|
* @param JukeboxService $jukebox |
|
38
|
|
|
* @param MapStorage $mapStorage |
|
39
|
|
|
* @param ChatNotification $chatNotification |
|
40
|
|
|
* @param int $duration |
|
41
|
|
|
* @param float $ratio |
|
42
|
|
|
*/ |
|
43
|
3 |
|
public function __construct( |
|
44
|
|
|
PlayerStorage $playerStorage, |
|
45
|
|
|
JukeboxService $jukebox, |
|
46
|
|
|
MapStorage $mapStorage, |
|
47
|
|
|
ChatNotification $chatNotification, |
|
48
|
|
|
int $duration, |
|
49
|
|
|
float $ratio |
|
50
|
|
|
) { |
|
51
|
3 |
|
parent::__construct($playerStorage, $duration, $ratio); |
|
52
|
|
|
|
|
53
|
3 |
|
$this->jukebox = $jukebox; |
|
54
|
3 |
|
$this->mapStorage = $mapStorage; |
|
55
|
|
|
|
|
56
|
3 |
|
$this->chatNotification = $chatNotification; |
|
57
|
3 |
|
} |
|
58
|
|
|
|
|
59
|
2 |
|
public function start(Player $player, $params) |
|
60
|
|
|
{ |
|
61
|
2 |
|
$this->map = $this->mapStorage->getCurrentMap(); |
|
62
|
|
|
|
|
63
|
2 |
|
return parent::start($player, $params); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @inheritdoc |
|
68
|
|
|
*/ |
|
69
|
1 |
|
public function getQuestion(): string |
|
70
|
|
|
{ |
|
71
|
1 |
|
return 'expansion_votemanager.restartmap.question'; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @inheritdoc |
|
76
|
|
|
*/ |
|
77
|
1 |
|
public function executeVotePassed() |
|
78
|
|
|
{ |
|
79
|
1 |
|
$this->jukebox->addMap($this->map, $this->getCurrentVote()->getPlayer()->getLogin(), |
|
80
|
1 |
|
true, true); |
|
81
|
1 |
|
$this->chatNotification->sendMessage("|info| Vote passed. Will replay map!"); |
|
82
|
1 |
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @inheritdoc |
|
86
|
|
|
*/ |
|
87
|
1 |
|
protected function executeVoteFailed() |
|
88
|
|
|
{ |
|
89
|
|
|
// Do Nothing |
|
90
|
1 |
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Get type code of this vote. |
|
94
|
|
|
* |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
3 |
|
public function getCode(): string |
|
98
|
|
|
{ |
|
99
|
3 |
|
return 'Exp_RestartMap'; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Get native votes this votes replaces. |
|
104
|
|
|
* |
|
105
|
|
|
* @return string[] |
|
106
|
|
|
*/ |
|
107
|
1 |
|
public function getReplacementTypes(): array |
|
108
|
|
|
{ |
|
109
|
1 |
|
return ['RestartMap']; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|