├── README.md ├── custom_form ├── dropdown.json ├── input.json ├── label.json ├── slider.json ├── step_slider.json └── toggle.json ├── form ├── TestForm │ ├── plugin.yml │ ├── resources │ │ └── form.json │ └── src │ │ └── nlog │ │ └── TestForm.php ├── form.jpg └── form.json └── modal ├── TestModal ├── plugin.yml ├── resources │ └── modal.json └── src │ └── nlog │ └── TestModal.php └── modal.json /README.md: -------------------------------------------------------------------------------- 1 | # Form_Json 2 | JSON mode for mcpe 1.2's ModalFormRequestPacket 3 | -------------------------------------------------------------------------------- /custom_form/dropdown.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "custom_form", 3 | "title": "dropdown", 4 | "content": [ 5 | { 6 | "type": "dropdown", 7 | "text": "dropdown test", 8 | "options": ["hello", "world"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /custom_form/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "custom_form", 3 | "title": "Input Text!", 4 | "content": [ 5 | { 6 | "type": "input", 7 | "text": "Input Text!", 8 | "default": "Steve" 9 | }, 10 | { 11 | "type": "input", 12 | "text": "Input Text!", 13 | "placeholder": "In-Game Name" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /custom_form/label.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "custom_form", 3 | "title": "label", 4 | "content": [ 5 | { 6 | "type": "label", 7 | "text": "It is text" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /custom_form/slider.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "custom_form", 3 | "title": "Slider Test", 4 | "content": [ 5 | { 6 | "type": "slider", 7 | "text": "Slider Test", 8 | "min": 0, 9 | "max": 100 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /custom_form/step_slider.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "custom_form", 3 | "title": "step_slider test", 4 | "content": [ 5 | { 6 | "type": "step_slider", 7 | "text": "step_slider test", 8 | "steps": ["0", "1", "2", "3", "4", "5"] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /custom_form/toggle.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "custom_form", 3 | "title": "toggle", 4 | "content": [ 5 | { 6 | "type": "toggle", 7 | "text": "toggle test", 8 | "default": false 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /form/TestForm/plugin.yml: -------------------------------------------------------------------------------- 1 | name: TestForm 2 | version: "1.0" 3 | api: 4 | - 3.0.0-ALPHA7 5 | author: nlog 6 | main: nlog\TestForm 7 | commands: 8 | form: 9 | description: test -------------------------------------------------------------------------------- /form/TestForm/resources/form.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "form", 3 | "title": "§eform test", 4 | "content": "This is form.\nForm has buttons.", 5 | "buttons": [ 6 | { 7 | "text": "Button 0", 8 | "image": { 9 | "type": "url", 10 | "data": "https://github.com/NLOGPlugins/Form_Json/blob/master/form/form.jpg?raw=true" 11 | } 12 | }, 13 | { 14 | "text": "Button 1", 15 | "image": { 16 | "type": "url", 17 | "data": "https://github.com/NLOGPlugins/Form_Json/blob/master/form/form.jpg?raw=true" 18 | } 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /form/TestForm/src/nlog/TestForm.php: -------------------------------------------------------------------------------- 1 | getServer()->getPluginManager()->registerEvents($this, $this); 17 | 18 | @mkdir($this->getDataFolder()); 19 | $this->saveResource("form.json"); 20 | } 21 | 22 | public function onRecievePacket (DataPacketReceiveEvent $ev): void { 23 | $pk = $ev->getPacket(); 24 | if ($pk instanceof ModalFormResponsePacket) { 25 | if ($pk->formId === 7654) { 26 | $data = json_decode($pk->formData, true); 27 | $ev->getPlayer()->sendMessage("You select no. {$data} button"); 28 | } 29 | } 30 | } 31 | 32 | public function onCommand(CommandSender $sender,Command $command,string $label,array $args): bool { 33 | $dir = file_get_contents($this->getDataFolder() . "form.json"); 34 | $pk = new ModalFormRequestPacket(); 35 | $pk->formId = 7654; 36 | $pk->formData = $dir; 37 | 38 | $sender->dataPacket($pk); 39 | return true; 40 | } 41 | 42 | 43 | } 44 | 45 | ?> -------------------------------------------------------------------------------- /form/form.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NLOGPlugins/Form_Json/cdec6604cbfaf743b1553a485b3a929db20330dc/form/form.jpg -------------------------------------------------------------------------------- /form/form.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "form", 3 | "title": "§eform test", 4 | "content": "This is form.\nForm has buttons.", 5 | "buttons": [ 6 | { 7 | "text": "Button 0", 8 | "image": { 9 | "type": "url", 10 | "data": "https://github.com/NLOGPlugins/Form_Json/blob/master/form/form.jpg?raw=true" 11 | } 12 | }, 13 | { 14 | "text": "Button 1", 15 | "image": { 16 | "type": "url", 17 | "data": "https://github.com/NLOGPlugins/Form_Json/blob/master/form/form.jpg?raw=true" 18 | } 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /modal/TestModal/plugin.yml: -------------------------------------------------------------------------------- 1 | name: TestModal 2 | version: "1.0" 3 | api: 4 | - 3.0.0-ALPHA7 5 | author: nlog 6 | main: nlog\TestModal 7 | commands: 8 | modal: 9 | description: test -------------------------------------------------------------------------------- /modal/TestModal/resources/modal.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "modal", 3 | "title": "modal test", 4 | "content": "This is modal.", 5 | "button1": "Button 1", 6 | "button2": "Button 2" 7 | } 8 | -------------------------------------------------------------------------------- /modal/TestModal/src/nlog/TestModal.php: -------------------------------------------------------------------------------- 1 | getServer()->getPluginManager()->registerEvents($this, $this); 19 | 20 | @mkdir($this->getDataFolder()); 21 | $this->saveResource("modal.json"); 22 | } 23 | 24 | public function onRecievePacket (DataPacketReceiveEvent $ev): void { 25 | $pk = $ev->getPacket(); 26 | if ($pk instanceof ModalFormResponsePacket) { 27 | if ($pk->formId === 1964) { 28 | $data = json_decode($pk->formData, true); 29 | if ($data) { 30 | $data = "true"; 31 | }else{ 32 | $data = "false"; 33 | } 34 | $ev->getPlayer()->sendMessage("You select {$data} button"); 35 | } 36 | } 37 | } 38 | 39 | public function onCommand(CommandSender $sender,Command $command,string $label,array $args): bool { 40 | $dir = file_get_contents($this->getDataFolder() . "modal.json"); 41 | $pk = new ModalFormRequestPacket(); 42 | $pk->formId = 1964; 43 | $pk->formData = $dir; 44 | 45 | $sender->dataPacket($pk); 46 | return true; 47 | } 48 | 49 | 50 | } 51 | 52 | ?> -------------------------------------------------------------------------------- /modal/modal.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "modal", 3 | "title": "modal test", 4 | "content": "This is modal.", 5 | "button1": "True Button", 6 | "button2": "False Button" 7 | } --------------------------------------------------------------------------------