|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Framework\GameTrackmania\DataProviders; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Framework\Core\DataProviders\AbstractDataProvider; |
|
6
|
|
|
use eXpansion\Framework\Core\ScriptMethods\AbstractScriptMethod; |
|
7
|
|
|
use eXpansion\Framework\Core\DataProviders\MethodScriptDataProviderInterface; |
|
8
|
|
|
use eXpansion\Framework\Core\Services\DedicatedConnection\Factory; |
|
9
|
|
|
use Maniaplanet\DedicatedServer\Connection; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class MethodGetStoresDataProvider |
|
14
|
|
|
* |
|
15
|
|
|
* @author de Cramer Oliver<[email protected]> |
|
16
|
|
|
* @copyright 2017 eXpansion |
|
17
|
|
|
* @package eXpansion\Framework\GameManiaplanet\DataProviders |
|
18
|
|
|
*/ |
|
19
|
|
|
class MethodGetScoresDataProvider extends AbstractDataProvider implements MethodScriptDataProviderInterface |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var Factory */ |
|
22
|
|
|
protected $factory; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* MethodGetScoresDataProvider constructor. |
|
26
|
|
|
* |
|
27
|
|
|
* @param Factory $factory |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct(Factory $factory) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->factory = $factory; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @inheritdoc |
|
36
|
|
|
* |
|
37
|
|
|
* @param string $pluginId |
|
38
|
|
|
* @param AbstractScriptMethod $pluginService |
|
39
|
|
|
*/ |
|
40
|
|
|
public function registerPlugin($pluginId, $pluginService) |
|
41
|
|
|
{ |
|
42
|
|
|
parent::registerPlugin($pluginId, $pluginService); |
|
43
|
|
|
|
|
44
|
|
|
$pluginService->setCurrentDataProvider($this); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Request call to fetch scores. |
|
50
|
|
|
* |
|
51
|
|
|
* @return void |
|
52
|
|
|
* @throws |
|
53
|
|
|
*/ |
|
54
|
|
|
public function request() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->factory->getConnection()->triggerModeScriptEvent("Trackmania.GetScores", ["responseid" => (string) time()]); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Set scores. |
|
61
|
|
|
* |
|
62
|
|
|
* @param array $params |
|
63
|
|
|
*/ |
|
64
|
|
|
public function setScores($params) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->dispatch('set', [$params]); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|