forked from jaylac2000/ScoreHud-Addons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OnlineTimeAddon.php
47 lines (38 loc) · 1.28 KB
/
OnlineTimeAddon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types = 1);
/**
* @name OnlineTimeAddon
* @version 1.0.0
* @main JackMD\ScoreHud\Addons\OnlineTimeAddon
* @depend OnlineTime
*/
namespace JackMD\ScoreHud\Addons {
use JackMD\ScoreHud\addon\AddonBase;
use pocketmine\Player;
use Zedstar16\OnlineTime\Main;
class OnlineTimeAddon extends AddonBase{
/** @var OnlineTime */
private $onlinetime;
public function onEnable() : void{
$this->onlinetime = $this->getServer()->getPluginManager()->getPlugin("OnlineTime");
}
/**
* @param Player $player
* @return array
*/
public function getProcessedTags(Player $player): array{
return [
"{total_time}" => $this->getTotal($player->getName()),
"{session_time}" => $this->getSession($player->getName()),
];
}
public function getTotal($pn){
$pn = strtolower($pn);
return isset(Main::$times[$pn]) ? $this->onlinetime->getTotalTime($pn) : "Error";
}
public function getSession($pn){
$pn = strtolower($pn);
return isset(Main::$times[$pn]) ? $this->onlinetime->getSessionTime($pn) : "Error";
}
}
}