PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
SetDisplayObjectivePacket.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;
16
18
20 public const NETWORK_ID = ProtocolInfo::SET_DISPLAY_OBJECTIVE_PACKET;
21
22 public const DISPLAY_SLOT_LIST = "list";
23 public const DISPLAY_SLOT_SIDEBAR = "sidebar";
24 public const DISPLAY_SLOT_BELOW_NAME = "belowname";
25
26 public const SORT_ORDER_ASCENDING = 0;
27 public const SORT_ORDER_DESCENDING = 1;
28
29 public string $displaySlot;
30 public string $objectiveName;
31 public string $displayName;
32 public string $criteriaName;
33 public int $sortOrder;
34
38 public static function create(string $displaySlot, string $objectiveName, string $displayName, string $criteriaName, int $sortOrder) : self{
39 $result = new self;
40 $result->displaySlot = $displaySlot;
41 $result->objectiveName = $objectiveName;
42 $result->displayName = $displayName;
43 $result->criteriaName = $criteriaName;
44 $result->sortOrder = $sortOrder;
45 return $result;
46 }
47
48 protected function decodePayload(PacketSerializer $in) : void{
49 $this->displaySlot = $in->getString();
50 $this->objectiveName = $in->getString();
51 $this->displayName = $in->getString();
52 $this->criteriaName = $in->getString();
53 $this->sortOrder = $in->getVarInt();
54 }
55
56 protected function encodePayload(PacketSerializer $out) : void{
57 $out->putString($this->displaySlot);
58 $out->putString($this->objectiveName);
59 $out->putString($this->displayName);
60 $out->putString($this->criteriaName);
61 $out->putVarInt($this->sortOrder);
62 }
63
64 public function handle(PacketHandlerInterface $handler) : bool{
65 return $handler->handleSetDisplayObjective($this);
66 }
67}
static create(string $displaySlot, string $objectiveName, string $displayName, string $criteriaName, int $sortOrder)