Skip to content

Commit 4c68c81

Browse files
authored
Merge pull request #6 from wode490390/patch-1
Import global functions and constants for enhanced performance
2 parents a128d82 + 93a9cb9 commit 4c68c81

3 files changed

Lines changed: 193 additions & 196 deletions

File tree

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
<?php
2-
declare(strict_types = 1);
2+
3+
declare(strict_types=1);
4+
35
namespace Anders\PlayerJoinSettings\API;
46

57
use pocketmine\Player;
68
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
9+
use function json_encode;
710

8-
class ModalForm extends RootUIAPI
9-
{
11+
class ModalForm extends RootUIAPI {
1012

1113
public $id;
12-
1314
private $data = [];
14-
1515
private $content = "";
16-
1716
public $playerName;
1817

1918
/**
20-
* I创建选择性UI
19+
* I创建选择性UI
2120
*
2221
* @param int $id
2322
*/
24-
public function __construct(int $id)
25-
{
23+
public function __construct(int $id) {
2624
parent::__construct($id);
2725
$this->data["type"] = "modal";
2826
$this->data["title"] = "";
@@ -32,13 +30,12 @@ public function __construct(int $id)
3230
}
3331

3432
/**
35-
* UI表单发送至玩家
33+
* UI表单发送至玩家
3634
*
3735
* {@inheritdoc}
3836
* @see Anders\PlayerJoinSettings\API\RootUIAPI::sendToPlayer()
3937
*/
40-
public function sendToPlayer(Player $player): void
41-
{
38+
public function sendToPlayer(Player $player): void {
4239
$pk = new ModalFormRequestPacket();
4340
$pk->formId = $this->id;
4441
$pk->formData = json_encode($this->data);
@@ -47,42 +44,39 @@ public function sendToPlayer(Player $player): void
4744
}
4845

4946
/**
50-
* UI 标题
47+
* UI 标题
5148
*
5249
* @param string $title
5350
*/
54-
public function setTitle(string $title): void
55-
{
51+
public function setTitle(string $title): void {
5652
$this->data["title"] = $title;
5753
}
5854

5955
/**
60-
* UI标题
56+
* UI标题
6157
*
6258
* @param string $content
6359
*/
64-
public function setContent(string $content): void
65-
{
60+
public function setContent(string $content): void {
6661
$this->data["content"] = $content;
6762
}
6863

6964
/**
70-
* UI第一个按钮
65+
* UI第一个按钮
7166
*
7267
* @param string $text
7368
*/
74-
public function setButton1(string $text): void
75-
{
69+
public function setButton1(string $text): void {
7670
$this->data["button1"] = $text;
7771
}
7872

7973
/**
80-
* UI 第二个按钮
74+
* UI 第二个按钮
8175
*
8276
* @param string $text
8377
*/
84-
public function setButton2(string $text): void
85-
{
78+
public function setButton2(string $text): void {
8679
$this->data["button2"] = $text;
8780
}
81+
8882
}
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Anders\PlayerJoinSettings\API;
36

47
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
58
use pocketmine\Player;
9+
use function json_encode;
610

7-
abstract class RootUIAPI
8-
{
11+
abstract class RootUIAPI {
912

1013
private $data = [];
11-
1214
public $id;
13-
14-
private $callable;
15-
1615
public $playerName;
1716

1817
/**
19-
*
2018
* @param String|int $id
2119
*/
22-
public function __construct($id)
23-
{
20+
public function __construct($id) {
2421
$this->id = $id;
2522
}
2623

27-
public function sendToPlayer(Player $player): void
28-
{
24+
public function sendToPlayer(Player $player): void {
2925
$pk = new ModalFormRequestPacket();
3026
$pk->formId = $this->id;
3127
$pk->formData = json_encode($this->data);
3228
$player->dataPacket($pk);
3329
$this->playerName = $player->getName();
3430
}
31+
3532
}

0 commit comments

Comments
 (0)