forked from ifera-mc/ScoreHud-Addons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RankUpAddon.php
66 lines (56 loc) · 1.31 KB
/
RankUpAddon.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types = 1);
/**
* @name RankUpAddon
* @version 1.0.0
* @main JackMD\ScoreHud\Addons\RankUpAddon
* @depend RankUp
*/
namespace JackMD\ScoreHud\Addons
{
use JackMD\ScoreHud\addon\AddonBase;
use pocketmine\Player;
use rankup\rank\Rank;
use rankup\RankUp;
class RankUpAddon extends AddonBase{
/** @var RankUp */
private $rankUp;
public function onEnable(): void{
$this->rankUp = $this->getServer()->getPluginManager()->getPlugin("RankUp");
}
/**
* @param Player $player
* @return array
*/
public function getProcessedTags(Player $player): array{
return [
"{prison_rank}" => $this->getRankUpRank($player),
"{prison_next_rank_price}" => $this->getRankUpRankPrice($player)
];
}
/**
* @param Player $player
* @return bool|int|string
*/
public function getRankUpRank(Player $player){
$group = $this->rankUp->getRankUpDoesGroups()->getPlayerGroup($player);
if($group !== false){
return $group;
}else{
return "No Rank";
}
}
/**
* @param Player $player
* @return bool|Rank|string
*/
public function getRankUpRankPrice(Player $player){
$nextRank = $this->rankUp->getRankStore()->getNextRank($player);
if($nextRank !== false){
return $nextRank->getPrice();
}else{
return "Max Rank";
}
}
}
}