-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPU_Info.php
More file actions
61 lines (54 loc) · 1.57 KB
/
CPU_Info.php
File metadata and controls
61 lines (54 loc) · 1.57 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
<?php
/**
* @name CPU_Info
* @author Security-Development
* @main CPU_Info\CPU_Info
* @version 0.1.0
* @api 3.13.0
*/
namespace CPU_Info;
use pocketmine\{
plugin\PluginBase,
event\Listener
};
class CPU_Info extends PluginBase implements Listener
{
public $cpu_info;
function onEnable() :void
{
$server = \pocketmine\Server::getInstance();
$server->getPluginManager()->registerEvents($this, $this);
$a = "grep ^'model name' /proc/cpuinfo";
$b = "top -b -n1 | grep -Po '[0-9.]+ id' | awk '{print 100-$1}'";
$this->cpu_info['cpu'] = function (\pocketmine\Player $player) use($server, $a ,$b): void
{
$msg = "§a[ CPU 정보 ]\nCPU 모델 : " . system($a)."\nCPU 사용률 : ". system($b) . "%";
$player->sendMessage($msg);
};
$server->getCommandMap()->registerAll('cpu', [
new class($this) extends \pocketmine\command\Command
{
public function __construct($plugin)
{
$this->plugin = $plugin;
parent::__construct (
'cpu',
'cpu info'
);
$this->setPermission('op');
}
function execute(\pocketmine\command\CommandSender $sender, $commandLabel, array $args) :bool
{
$this->plugin->cpu_info['cpu']($sender);
return false;
}
}
]);
}
function onJoin(\pocketmine\event\player\PlayerJoinEvent $event): void
{
$player = $event->getPlayer();
$this->cpu_info['cpu']($player);
}
}
?>