Created
June 13, 2020 06:23
-
-
Save PJZ9n/a35ab569d0aeb757c0bc0e84ca2614b5 to your computer and use it in GitHub Desktop.
Test for ServerSettings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @name SSTest | |
* @version 1.0.0 | |
* @main PJZ9n\SSTest\SSTest | |
* @api 3.12.0 | |
*/ | |
declare(strict_types=1); | |
namespace PJZ9n\SSTest; | |
use pocketmine\event\Listener; | |
use pocketmine\event\player\PlayerJoinEvent; | |
use pocketmine\form\Form; | |
use pocketmine\Player; | |
use pocketmine\plugin\PluginBase; | |
class SSTest extends PluginBase implements Listener | |
{ | |
public function onEnable(): void | |
{ | |
$this->getServer()->getPluginManager()->registerEvents($this, $this); | |
} | |
public function onPlayerJoin(PlayerJoinEvent $event): void | |
{ | |
$player = $event->getPlayer(); | |
$player->setServerSettingsForm(new class implements Form { | |
public function handleResponse(Player $player, $data): void | |
{ | |
var_dump($player->getName(), $data); | |
} | |
public function jsonSerialize(): array | |
{ | |
return [ | |
"type" => "custom_form", | |
"icon" => [ | |
"type" => "path", | |
"data" => "textures/items/apple", | |
], | |
"title" => "Settings!", | |
"content" => [ | |
[ | |
"type" => "label", | |
"text" => "example settings.", | |
], | |
[ | |
"type" => "input", | |
"text" => "Please input.", | |
"default" => date("Y/m/d H:i:s"), | |
], | |
], | |
]; | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment