PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
EducationSettingsPacket.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
20
22 public const NETWORK_ID = ProtocolInfo::EDUCATION_SETTINGS_PACKET;
23
24 private string $codeBuilderDefaultUri;
25 private string $codeBuilderTitle;
26 private bool $canResizeCodeBuilder;
27 private bool $disableLegacyTitleBar;
28 private string $postProcessFilter;
29 private string $screenshotBorderResourcePath;
30 private ?EducationSettingsAgentCapabilities $agentCapabilities;
31 private ?string $codeBuilderOverrideUri;
32 private bool $hasQuiz;
33 private ?EducationSettingsExternalLinkSettings $linkSettings;
34
38 public static function create(
39 string $codeBuilderDefaultUri,
40 string $codeBuilderTitle,
41 bool $canResizeCodeBuilder,
42 bool $disableLegacyTitleBar,
43 string $postProcessFilter,
44 string $screenshotBorderResourcePath,
45 ?EducationSettingsAgentCapabilities $agentCapabilities,
46 ?string $codeBuilderOverrideUri,
47 bool $hasQuiz,
49 ) : self{
50 $result = new self;
51 $result->codeBuilderDefaultUri = $codeBuilderDefaultUri;
52 $result->codeBuilderTitle = $codeBuilderTitle;
53 $result->canResizeCodeBuilder = $canResizeCodeBuilder;
54 $result->disableLegacyTitleBar = $disableLegacyTitleBar;
55 $result->postProcessFilter = $postProcessFilter;
56 $result->screenshotBorderResourcePath = $screenshotBorderResourcePath;
57 $result->agentCapabilities = $agentCapabilities;
58 $result->codeBuilderOverrideUri = $codeBuilderOverrideUri;
59 $result->hasQuiz = $hasQuiz;
60 $result->linkSettings = $linkSettings;
61 return $result;
62 }
63
64 public function getCodeBuilderDefaultUri() : string{
65 return $this->codeBuilderDefaultUri;
66 }
67
68 public function getCodeBuilderTitle() : string{
69 return $this->codeBuilderTitle;
70 }
71
72 public function canResizeCodeBuilder() : bool{
73 return $this->canResizeCodeBuilder;
74 }
75
76 public function disableLegacyTitleBar() : bool{ return $this->disableLegacyTitleBar; }
77
78 public function getPostProcessFilter() : string{ return $this->postProcessFilter; }
79
80 public function getScreenshotBorderResourcePath() : string{ return $this->screenshotBorderResourcePath; }
81
82 public function getAgentCapabilities() : ?EducationSettingsAgentCapabilities{ return $this->agentCapabilities; }
83
84 public function getCodeBuilderOverrideUri() : ?string{
85 return $this->codeBuilderOverrideUri;
86 }
87
88 public function getHasQuiz() : bool{
89 return $this->hasQuiz;
90 }
91
92 public function getLinkSettings() : ?EducationSettingsExternalLinkSettings{ return $this->linkSettings; }
93
94 protected function decodePayload(PacketSerializer $in) : void{
95 $this->codeBuilderDefaultUri = $in->getString();
96 $this->codeBuilderTitle = $in->getString();
97 $this->canResizeCodeBuilder = $in->getBool();
98 $this->disableLegacyTitleBar = $in->getBool();
99 $this->postProcessFilter = $in->getString();
100 $this->screenshotBorderResourcePath = $in->getString();
101 $this->agentCapabilities = $in->readOptional(fn() => EducationSettingsAgentCapabilities::read($in));
102 $this->codeBuilderOverrideUri = $in->readOptional($in->getString(...));
103 $this->hasQuiz = $in->getBool();
104 $this->linkSettings = $in->readOptional(fn() => EducationSettingsExternalLinkSettings::read($in));
105 }
106
107 protected function encodePayload(PacketSerializer $out) : void{
108 $out->putString($this->codeBuilderDefaultUri);
109 $out->putString($this->codeBuilderTitle);
110 $out->putBool($this->canResizeCodeBuilder);
111 $out->putBool($this->disableLegacyTitleBar);
112 $out->putString($this->postProcessFilter);
113 $out->putString($this->screenshotBorderResourcePath);
114 $out->writeOptional($this->agentCapabilities, fn(EducationSettingsAgentCapabilities $v) => $v->write($out));
115 $out->writeOptional($this->codeBuilderOverrideUri, $out->putString(...));
116 $out->putBool($this->hasQuiz);
117 $out->writeOptional($this->linkSettings, fn(EducationSettingsExternalLinkSettings $v) => $v->write($out));
118 }
119
120 public function handle(PacketHandlerInterface $handler) : bool{
121 return $handler->handleEducationSettings($this);
122 }
123}
static create(string $codeBuilderDefaultUri, string $codeBuilderTitle, bool $canResizeCodeBuilder, bool $disableLegacyTitleBar, string $postProcessFilter, string $screenshotBorderResourcePath, ?EducationSettingsAgentCapabilities $agentCapabilities, ?string $codeBuilderOverrideUri, bool $hasQuiz, ?EducationSettingsExternalLinkSettings $linkSettings,)