Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Last active September 21, 2020 19:47
Show Gist options
  • Save PJZ9n/4383a6affccf214823f367389c0ee24b to your computer and use it in GitHub Desktop.
Save PJZ9n/4383a6affccf214823f367389c0ee24b to your computer and use it in GitHub Desktop.
pmformsを使ったクラスベースのModalFormとそれの実装
<?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);
}
}
<?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