1 | <?php |
||
24 | class MxKarma implements StatusAwarePluginInterface, |
||
25 | ListenerInterfaceMpScriptMap, |
||
26 | ListenerInterfaceMpLegacyChat, |
||
27 | ListenerInterfaceExpApplication, |
||
28 | ListenerInterfaceMxKarma |
||
29 | { |
||
30 | |||
31 | |||
32 | /** @var MxVote[] */ |
||
33 | protected $changedVotes = []; |
||
34 | |||
35 | /** @var int */ |
||
36 | private $startTime; |
||
37 | /** |
||
38 | * @var object |
||
39 | */ |
||
40 | protected $config; |
||
41 | |||
42 | /** |
||
43 | * @var Console |
||
44 | */ |
||
45 | protected $console; |
||
46 | /** |
||
47 | * @var Dispatcher |
||
48 | */ |
||
49 | protected $dispatcher; |
||
50 | /** |
||
51 | * @var ChatNotification |
||
52 | */ |
||
53 | protected $chatNotification; |
||
54 | |||
55 | /** |
||
56 | * @var MxKarmaService |
||
57 | */ |
||
58 | private $mxKarma; |
||
59 | |||
60 | /** @var MxRating */ |
||
61 | private $mxRating; |
||
62 | |||
63 | /** @var MxVote[] */ |
||
64 | private $votes; |
||
65 | /** |
||
66 | * @var PlayerStorage |
||
67 | */ |
||
68 | private $playerStorage; |
||
69 | /** |
||
70 | * @var ConfigInterface |
||
71 | */ |
||
72 | private $apikey; |
||
73 | /** |
||
74 | * @var ConfigInterface |
||
75 | */ |
||
76 | private $serverLogin; |
||
77 | /** |
||
78 | * @var GameDataStorage |
||
79 | */ |
||
80 | private $gameDataStorage; |
||
81 | /** |
||
82 | * @var ConfigInterface |
||
83 | */ |
||
84 | private $enabled; |
||
85 | |||
86 | /** |
||
87 | * MxKarma constructor. |
||
88 | * @param ConfigInterface $enabled |
||
89 | * @param ConfigInterface $apikey |
||
90 | * @param ConfigInterface $serverLogin |
||
91 | * @param MxKarmaService $mxKarma |
||
92 | * @param Console $console |
||
93 | * @param ChatNotification $chatNotification |
||
94 | * @param Dispatcher $dispatcher |
||
95 | * @param PlayerStorage $playerStorage |
||
96 | * @param GameDataStorage $gameDataStorage |
||
97 | */ |
||
98 | public function __construct( |
||
120 | |||
121 | /** |
||
122 | * sets vote value |
||
123 | * @param $login |
||
124 | * @param $vote |
||
125 | */ |
||
126 | public function setVote($login, $vote) |
||
139 | |||
140 | |||
141 | /** |
||
142 | * Set the status of the plugin |
||
143 | * |
||
144 | * @param boolean $status |
||
145 | * |
||
146 | * @return null |
||
147 | */ |
||
148 | public function setStatus($status) |
||
152 | |||
153 | /** |
||
154 | * Called when a player chats. |
||
155 | * |
||
156 | * @param Player $player |
||
157 | * @param $text |
||
158 | * |
||
159 | * @return void |
||
160 | */ |
||
161 | public function onPlayerChat(Player $player, $text) |
||
179 | |||
180 | |||
181 | /** |
||
182 | * called at eXpansion init |
||
183 | * |
||
184 | * @return void |
||
185 | */ |
||
186 | public function onApplicationInit() |
||
190 | |||
191 | /** |
||
192 | * called when init is done and callbacks are enabled |
||
193 | * |
||
194 | * @return void |
||
195 | */ |
||
196 | public function onApplicationReady() |
||
202 | |||
203 | /** |
||
204 | * called when requesting application stop |
||
205 | * |
||
206 | * @return void |
||
207 | */ |
||
208 | public function onApplicationStop() |
||
212 | |||
213 | /** |
||
214 | * |
||
215 | */ |
||
216 | public function onMxKarmaConnect() |
||
220 | |||
221 | /** |
||
222 | * @param MxRating $mxRating |
||
223 | * @return void |
||
224 | */ |
||
225 | public function onMxKarmaVoteLoad(MxRating $mxRating) |
||
246 | |||
247 | /** |
||
248 | * @param MxVote[] $updatedVotes |
||
249 | * @return void |
||
250 | */ |
||
251 | public function onMxKarmaVoteSave($updatedVotes) |
||
255 | |||
256 | public function onMxKarmaDisconnect() |
||
260 | |||
261 | /** |
||
262 | * Callback sent when the "StartMap" section start. |
||
263 | * |
||
264 | * @param int $count Each time this section is played, this number is incremented by one |
||
265 | * @param int $time Server time when the callback was sent |
||
266 | * @param boolean $restarted true if the map was restarted, false otherwise |
||
267 | * @param Map $map Map started with. |
||
268 | * |
||
269 | * @return void |
||
270 | */ |
||
271 | public function onStartMapStart($count, $time, $restarted, Map $map) |
||
280 | |||
281 | /** |
||
282 | * Callback sent when the "StartMap" section end. |
||
283 | * |
||
284 | * @param int $count Each time this section is played, this number is incremented by one |
||
285 | * @param int $time Server time when the callback was sent |
||
286 | * @param boolean $restarted true if the map was restarted, false otherwise |
||
287 | * @param Map $map Map started with. |
||
288 | * |
||
289 | * @return void |
||
290 | */ |
||
291 | public function onStartMapEnd($count, $time, $restarted, Map $map) |
||
296 | |||
297 | /** |
||
298 | * Callback sent when the "EndMap" section start. |
||
299 | * |
||
300 | * @param int $count Each time this section is played, this number is incremented by one |
||
301 | * @param int $time Server time when the callback was sent |
||
302 | * @param boolean $restarted true if the map was restarted, false otherwise |
||
303 | * @param Map $map Map started with. |
||
304 | * |
||
305 | * @return void |
||
306 | */ |
||
307 | public function onEndMapStart($count, $time, $restarted, Map $map) |
||
311 | |||
312 | /** |
||
313 | * Callback sent when the "EndMap" section end. |
||
314 | * |
||
315 | * @param int $count Each time this section is played, this number is incremented by one |
||
316 | * @param int $time Server time when the callback was sent |
||
317 | * @param boolean $restarted true if the map was restarted, false otherwise |
||
318 | * @param Map $map Map started with. |
||
319 | * |
||
320 | * @return void |
||
321 | */ |
||
322 | public function onEndMapEnd($count, $time, $restarted, Map $map) |
||
334 | |||
335 | protected function connect() |
||
359 | |||
360 | |||
361 | } |
||
362 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.