-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathForm.php
More file actions
84 lines (71 loc) · 1.99 KB
/
Copy pathForm.php
File metadata and controls
84 lines (71 loc) · 1.99 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
<?php
/**
* _ _ _ __
* | (_) | / _|
* | |_| |__ | |_ ___ _ __ _ __ ___ ___
* | | | '_ \| _/ _ \| '__| '_ ` _ \/ __|
* | | | |_) | || (_) | | | | | | | \__ \
* |_|_|_.__/|_| \___/|_| |_| |_| |_|___/
*
* Copyright (C) 2016-2026 NetherGames Network
*
* This is private software, you cannot redistribute and/or modify it in any way
* unless given explicit permission to do so. If you have not been given explicit
* permission to view or modify this software you should take the appropriate actions
* to remove this software from your device immediately.
*
* @author matcracker, driesboy
*
*/
declare(strict_types=1);
namespace libforms;
use NetherGames\NGEssentials\player\NGPlayer;
use pocketmine\form\Form as IForm;
use pocketmine\network\PacketHandlingException;
use pocketmine\player\Player;
abstract class Form implements IForm
{
/** @var string */
private string $title = '';
/** @var Player|null */
private ?Player $player;
public function __construct(?Player $player)
{
$this->player = $player;
}
public function setTitle(string $title): void
{
$this->title = $title;
}
public function getTitle(): string
{
return $this->title;
}
public function sendForm(): void
{
/** @var NGPlayer $player */
$player = $this->getPlayer();
if (FormManager::canSend($player)) {
$player->sendForm(clone $this);
FormManager::scheduleNetworkStackLatency($player);
FormManager::sendLastForm($player);
}
}
public function getPlayer(): Player
{
if ($this->player === null) {
throw new PacketHandlingException('Tried to use player in a static form');
}
return $this->player;
}
public function setPlayer(Player $player): void
{
$this->player = $player;
}
public function jsonSerialize(): array
{
return [
'title' => $this->getTitle(),
];
}
}