PocketMine-MP 5.43.2 git-a137a986d01d9af23452b2e741699a770c7ae112
Loading...
Searching...
No Matches
SystemDiagnosticTimingInfo.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol\types;
16
17use pmmp\encoding\Byte;
18use pmmp\encoding\ByteBufferReader;
19use pmmp\encoding\ByteBufferWriter;
20use pmmp\encoding\LE;
22
24
25 public function __construct(
26 private string $displayName,
27 private int $systemIndex,
28 private int $timeInNS,
29 private int $percentOfTotal,
30 ){}
31
32 public function getDisplayName() : string{ return $this->displayName; }
33
34 public function getSystemIndex() : int{ return $this->systemIndex; }
35
36 public function getTimeInNS() : int{ return $this->timeInNS; }
37
38 public function getPercentOfTotal() : int{ return $this->percentOfTotal; }
39
40 public static function read(ByteBufferReader $in) : self{
41 $displayName = CommonTypes::getString($in);
42 $systemIndex = LE::readUnsignedLong($in);
43 $timeInNS = LE::readUnsignedLong($in);
44 $percentOfTotal = Byte::readUnsigned($in);
45
46 return new self(
47 $displayName,
48 $systemIndex,
49 $timeInNS,
50 $percentOfTotal
51 );
52 }
53
54 public function write(ByteBufferWriter $out) : void{
55 CommonTypes::putString($out, $this->displayName);
56 LE::writeUnsignedLong($out, $this->systemIndex);
57 LE::writeUnsignedLong($out, $this->timeInNS);
58 Byte::writeUnsigned($out, $this->percentOfTotal);
59 }
60}