This repository was archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathScoreboardTask.php
More file actions
86 lines (78 loc) · 3.6 KB
/
ScoreboardTask.php
File metadata and controls
86 lines (78 loc) · 3.6 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
declare(strict_types=1);
namespace ServerCore\task;
use pocketmine\scheduler\Task;
use ServerCore\ServerCore;
class ScoreboardTask extends Task {
private $plugin;
private $titleIndex;
public function __construct(ServerCore $plugin, int $titleIndex) {
$this->plugin = $plugin;
$this->titleIndex = $titleIndex;
}
public function onRun(int $currentTick) : void {
$this->titleIndex++;
$config = $this->plugin->getConfig();
$titles = is_array($config->get("title")) ? $config->get("title") : ["Your Server"];
// $lines = is_array($config->get("line")) ? $config->get("line") : ["Please update your config"];
if (!isset($titles[$this->titleIndex])) {
$this->titleIndex = 0;
}
$api = ServerCore::getInstance();
foreach ($this->plugin->getServer()->getOnlinePlayers() as $p) {
$player = $p->getPlayer();
$name = $player->getName();
$tps = $this->plugin->getServer()->getTicksPerSecond();
$usage = $this->plugin->getServer()->getTickUsage();
$online = $online = count($this->plugin->getServer()->getOnlinePlayers());
// $max_online = $this->plugin->getServer()->getMaxPlayers();
if ($this->plugin->getServer()->getPluginManager()->getPlugin("FactionsPro") !== null) {
$fac = $this->plugin->faction->getPlayerFaction($player);
} else {
$fac = null;
}
$x = round($player->getX(), 0);
$y = round($player->getY(), 0);
$z = round($player->getZ(), 0);
$group = $this->plugin->group->getUserDataMgr()->getGroup($player)->getName();
$money = $this->plugin->money->myMoney($player);
$item = $player->getInventory()->getItemInHand()->getName();
$id = $player->getInventory()->getItemInHand()->getId();
$ids = $player->getInventory()->getItemInHand()->getDamage();
$level = $player->getLevel()->getName();
$date = date("H.i");
if ($this->plugin->getServer()->getPluginManager()->getPlugin("KillChat") !== null) {
$kills = $this->plugin->killChat->getKills($name);
$deaths = $this->plugin->killChat->getDeaths($name);
} else {
$kills = null;
$deaths = null;
}
$ping = $player->getPing($name);
// $lines = $config->get("line");
$api->new($p, $p->getName(), $titles[$this->titleIndex]);
$api->setLine($player, 1, strval($name));
$api->setLine($player, 2, strval($tps));
$api->setLine($player, 3, strval($usage));
$api->setLine($player, 4, strval($online));
$api->setLine($player, 5, strval($x));
$api->setLine($player, 6, strval($y));
$api->setLine($player, 7, strval($z));
$api->setLine($player, 8, strval($item));
$api->setLine($player, 9, strval($level));
$api->setLine($player, 10, strval($ping));
$api->setLine($player, 11, strval($group));
$api->setLine($player, 12, strval($money));
if ($fac !== null) {
$api->setLine($player, 13, $fac);
} elseif ($kills !== null && $deaths !== null) {
$api->setLine($player, 13, $kills);
$api->setLine($player, 14, $deaths);
}
if ($kills !== null && $deaths !== null) {
$api->setLine($player, 14, $kills);
$api->setLine($player, 15, $deaths);
}
}
}
}