Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. <?php
  2.    
  3.     namespace your\name\space;
  4.    
  5.     use pocketmine\form\Form;
  6.     use pocketmine\Player;
  7.    
  8.     class ExampleForm implements Form
  9.     {
  10.        
  11.         public function jsonSerialize(): array
  12.         {
  13.             return [
  14.                 "type" => "form",
  15.                 "title" => "タイトル",
  16.                 "content" => "コンテンツ1\nコンテンツ2",
  17.                 "buttons" => [
  18.                     [
  19.                         "text" => "ボタン1",
  20.                     ],
  21.                     [
  22.                         "text" => "ボタン2",
  23.                     ],
  24.                     [
  25.                         "text" => "ボタン3",
  26.                     ],
  27.                     [
  28.                         "text" => "ボタン4",
  29.                     ],
  30.                 ],
  31.             ];
  32.         }
  33.        
  34.         public function handleResponse(Player $player, $data): void
  35.         {
  36.             if ($data === null) {
  37.                 return;
  38.             }
  39.             switch ($data) {
  40.                 case 0:
  41.                     //ボタン1
  42.                     break;
  43.                 case 1:
  44.                     //ボタン2
  45.                     break;
  46.                 case 2:
  47.                     //ボタン3
  48.                     break;
  49.                 case 3:
  50.                     //ボタン4
  51.                     break;
  52.             }
  53.         }
  54.        
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement