Created
April 22, 2020 23:34
-
-
Save PJZ9n/210ddc970764dacb2965fae52d245391 to your computer and use it in GitHub Desktop.
jojoe77777\FormAPIを扱うサンプル。動作未確認。
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 | |
declare(strict_types=1); | |
$form = new \jojoe77777\FormAPI\SimpleForm(function (\pocketmine\Player $player, $data): void { | |
if ($data === null) { | |
//閉じられた | |
return; | |
} | |
switch ($data) { | |
case 0: | |
//数を設定する | |
$form = new \jojoe77777\FormAPI\CustomForm(function (\pocketmine\Player $player, $data): void { | |
//設定された処理 | |
}); | |
$form->setTitle("数を設定する"); | |
$form->addSlider("設定する数", 0, 64); | |
$player->sendForm($form); | |
return; | |
case 1: | |
//りんごを食べるので閉じる | |
//何もしない | |
return; | |
} | |
//何も該当しない | |
throw new \pocketmine\form\FormValidationException(); | |
}); | |
$form->setTitle("選択フォーム"); | |
$form->setContent("選択してください"); | |
$form->addButton("数を設定する"); | |
$form->addButton("りんごを食べるので閉じる", \jojoe77777\FormAPI\SimpleForm::IMAGE_TYPE_PATH, "textures/items/apple"); | |
/** @var \pocketmine\Player $player */ | |
$player->sendForm($form); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment