Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Created May 14, 2020 05:45
Show Gist options
  • Save PJZ9n/70821cc3fa55684abb5a71a19656ca90 to your computer and use it in GitHub Desktop.
Save PJZ9n/70821cc3fa55684abb5a71a19656ca90 to your computer and use it in GitHub Desktop.
pocketmine\form\Formを無名クラスで使う
<?php
declare(strict_types=1);
namespace Author\PluginName;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\form\Form;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\utils\TextFormat;
class Main extends PluginBase
{
public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool
{
if (!$sender instanceof Player) {
$sender->sendMessage(TextFormat::RED . "プレイヤーから実行してください!");
return true;
}
$form = new class implements Form {
public function handleResponse(Player $player, $data): void
{
// TODO: Implement handleResponse() method.
}
public function jsonSerialize()
{
// TODO: Implement jsonSerialize() method.
}
};
$sender->sendForm($form);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment