You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scripts/protoform/README.md
+29-5Lines changed: 29 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# ProtoForm
2
2
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.
4
4
5
5
## Features
6
6
@@ -23,14 +23,16 @@ import { ProtoForm } from "./index.js";
23
23
```
24
24
### ModalForm
25
25
26
+
-**fields** key determines that it's a **ModalForm**
27
+
26
28
```js
27
29
constmodalForm=newProtoForm({
28
30
title:"Example Modal Form",
29
31
fields: [
30
-
["text", ["Label", "Placeholder", "Default"]],
31
-
["slider",["Label",2/* Min */,10/* Max */,2/*Step*/,6/*Default*/]],
@@ -40,6 +42,8 @@ const modalForm = new ProtoForm({
40
42
```
41
43
### MessageForm
42
44
45
+
-**btn1** and **btn2** determines that it's a **MessageForm**
46
+
43
47
```js
44
48
constmessageForm=newProtoForm({
45
49
title:"Example Message Form",
@@ -54,12 +58,17 @@ const messageForm = new ProtoForm({
54
58
```
55
59
### ActionForm
56
60
61
+
-**btns** key determine that it's an **ActionForm**
62
+
57
63
```js
58
64
constactionForm=newProtoForm({
59
65
title:"Example Action Form",
66
+
body:"Example Action Form Body",
60
67
btns: [
61
68
["Button 1", "path/to/btn1_texture"],
62
69
["Button 2", "path/to/btn2_texture"],
70
+
"Button 3",
71
+
["Button 4"],
63
72
// Add more buttons as needed
64
73
],
65
74
response: (data) => {
@@ -68,6 +77,7 @@ const actionForm = new ProtoForm({
68
77
}
69
78
});
70
79
```
80
+
71
81
### Showing Forms To Player
72
82
73
83
```js
@@ -76,5 +86,19 @@ modalForm.show(player);
76
86
messageForm.show(player);
77
87
actionForm.show(player);
78
88
```
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.
0 commit comments