Skip to content

Commit 5d4f470

Browse files
authored
Update README.md
1 parent 817b0e1 commit 5d4f470

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

scripts/protoform/README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ProtoForm
22

3-
**ProtoForm** is a versatile library for creating and managing various types of forms in your Minecraft server plugins. It simplifies the process of generating modal, message, and action forms, providing a clean and structured way to handle user input.
3+
**ProtoForm** simplifies the creation and management of Minecraft forms and responses. With a single class, it provides an efficient and easy way to generate various forms. This can save you time compared to the original approach, as minimal code is required. The form type is determined based on the keys/properties provided in the object, resulting in clean and concise code with reduced storage needs.
44

55
## Features
66

@@ -23,14 +23,16 @@ import { ProtoForm } from "./index.js";
2323
```
2424
### ModalForm
2525

26+
- **fields** key determines that it's a **ModalForm**
27+
2628
```js
2729
const modalForm = new ProtoForm({
2830
title: "Example Modal Form",
2931
fields: [
30-
["text", ["Label", "Placeholder", "Default"]],
31-
["slider",["Label",2/* Min */,10/* Max */,2/*Step*/,6/*Default*/]],
32-
["dropdown",["Label",["Option 1","Option 2", "Option 3"]/* Options */,1 /*Default*/]],
33-
["toggle",["Label",true /*default*/]]
32+
["text", "Label", "Placeholder", "Default"],
33+
["slider","Label",2/* Min */,10/* Max */,2/*Step*/,6/*Default*/],
34+
["dropdown","Label",["Option 1","Option 2", "Option 3"]/* Options */,1 /*Default*/],
35+
["toggle","Label",true /*default*/]
3436
],
3537
response: (data) => {
3638
// Handle form submission
@@ -40,6 +42,8 @@ const modalForm = new ProtoForm({
4042
```
4143
### MessageForm
4244

45+
- **btn1** and **btn2** determines that it's a **MessageForm**
46+
4347
```js
4448
const messageForm = new ProtoForm({
4549
title: "Example Message Form",
@@ -54,12 +58,17 @@ const messageForm = new ProtoForm({
5458
```
5559
### ActionForm
5660

61+
- **btns** key determine that it's an **ActionForm**
62+
5763
```js
5864
const actionForm = new ProtoForm({
5965
title: "Example Action Form",
66+
body: "Example Action Form Body",
6067
btns: [
6168
["Button 1", "path/to/btn1_texture"],
6269
["Button 2", "path/to/btn2_texture"],
70+
"Button 3",
71+
["Button 4"],
6372
// Add more buttons as needed
6473
],
6574
response: (data) => {
@@ -68,6 +77,7 @@ const actionForm = new ProtoForm({
6877
}
6978
});
7079
```
80+
7181
### Showing Forms To Player
7282

7383
```js
@@ -76,5 +86,19 @@ modalForm.show(player);
7686
messageForm.show(player);
7787
actionForm.show(player);
7888
```
89+
90+
### Case Errors
91+
92+
- When **fields** and **btn1** or **btn2** keys are used togethor, it throws error.
93+
94+
- When **fields** and **btns** keys are used togethor, it throws error.
95+
96+
- When **btns** and **btn1** or **btn2** keys are used togethor, it throws error.
97+
98+
- When **title** is missing, it throws error.
99+
100+
- When **body** is missing with **btns** or **btn1** and **btn2**, it throws error. => When **body** is missing in **MessageForm** or **ActionForm**, it throws error.
101+
102+
79103
## Author
80104
These Scripts Are Written By **GamerFile**

0 commit comments

Comments
 (0)