Created
September 26, 2020 16:03
-
-
Save PJZ9n/affec47afa2a09cd75967804111b72d3 to your computer and use it in GitHub Desktop.
pmformsでオートコンプリート実装例(非公式ブランチ)
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 | |
use dktapps\pmforms\CustomForm; | |
use dktapps\pmforms\CustomFormResponse; | |
use dktapps\pmforms\element\Input; | |
use pocketmine\Player; | |
$form = new CustomForm( | |
"example", | |
[ | |
new Input( | |
"test1", | |
"please input number" | |
), | |
], | |
function (Player $player, CustomFormResponse $response) use (&$form): void { | |
/** @var CustomForm $form */ | |
$test1Response = $response->getString("test1"); | |
if (preg_match("/^[0-9]+$/", $test1Response) !== 1) { | |
/** @var Input $test1Element */ | |
$test1Element = $form->getElementByName("test1"); | |
$test1Element->setDefaultText($test1Response); | |
$player->sendMessage("\"$test1Response\" is not an number!"); | |
$player->sendForm($form); | |
return; | |
} | |
$player->sendMessage("ok! input: " . $test1Response); | |
} | |
); | |
/** @var Player $player */ | |
$player->sendForm($form); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment