Last active
September 21, 2020 19:47
-
-
Save PJZ9n/4383a6affccf214823f367389c0ee24b to your computer and use it in GitHub Desktop.
pmformsを使ったクラスベースのModalFormとそれの実装
This file contains 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); | |
namespace pjz9n\classbasedpmforms; | |
use pocketmine\Player; | |
class ExampleForm extends ModalForm | |
{ | |
public function __construct() | |
{ | |
parent::__construct( | |
"Title", | |
"Text" | |
); | |
} | |
public function onSubmit(Player $player, bool $choice): void | |
{ | |
var_dump($choice); | |
} | |
} |
This file contains 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); | |
namespace pjz9n\classbasedpmforms; | |
use Closure; | |
use pocketmine\Player; | |
abstract class ModalForm extends \dktapps\pmforms\ModalForm | |
{ | |
public function __construct(string $title, string $text, string $yesButtonText = "gui.yes", string $noButtonText = "gui.no") | |
{ | |
parent::__construct($title, $text, Closure::fromCallable([$this, "onSubmit"]), $yesButtonText, $noButtonText); | |
} | |
abstract public function onSubmit(Player $player, bool $choice): void; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment