forked from zimzaza4/Skript-Floodgate-Api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skript_form_api.sk
255 lines (200 loc) · 8.01 KB
/
skript_form_api.sk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
import:
org.geysermc.floodgate.api.FloodgateApi
org.geysermc.cumulus.SimpleForm
org.geysermc.cumulus.ModalForm
org.geysermc.cumulus.CustomForm
org.geysermc.cumulus.util.FormBuilder
org.geysermc.cumulus.util.FormImage
org.geysermc.cumulus.util.FormType
org.geysermc.cumulus.util.ComponentType
org.bukkit.entity.Player
org.geysermc.cumulus.util.FormImage$Type
me.zimzaza4.LForm
me.zimzaza4.SimpleFormClickEvent
me.zimzaza4.ModalFormClickEvent
me.zimzaza4.CustomFormClickEvent
on CustomFormClickEvent:
set {_events::player} to event.getPlayer()
set {_extras::form-id} to event.getFormID()
set {_extras::response} to event.getResponse()
call custom event "submit custom form" with {_events::*} data {_extras::*}
on ModalFormClickEvent:
set {_events::player} to event.getPlayer()
set {_extras::form-id} to event.getFormId()
set {_extras::response} to event.getResponse()
set {_extras::button-id} to event.getButtonID()
set {_extras::button-name} to event.getButtonName()
call custom event "click button of form" with {_events::*} data {_extras::*}
on SimpleFormClickEvent:
set {_events::player} to event.getPlayer()
set {_extras::form-id} to event.getFormId()
set {_extras::response} to event.getResponse()
set {_extras::button-id} to event.getButtonID()
set {_extras::button-name} to event.getButtonName()
call custom event "click button of form" with {_events::*} data {_extras::*}
expression button id of %object%:
return type: number
get:
return expr-1.getButtonID()
expression form id of %object%:
return type: string
get:
if expr-1.getFormId() is not null:
set {_id} to expr-1.getFormId()
else if expr-1.getFormID() is not null:
set {_id} to expr-1.getFormID()
return {_id}
custom event "submit custom form":
pattern: submit custom form
event-values: player
custom event "click button of form":
pattern: click form button
event-values: player
expression [the] simple form with title %string%:
return type: object
get:
set {_F} to SimpleForm.builder().title(expr-1)
return {_F}
expression [the] custom form with title %string%:
return type: object
get:
set {_F} to CustomForm.builder().title(expr-1)
return {_F}
expression [the] modal form with title %string% and button[s] %string% %string%:
return type: object
get:
set {_F} to ModalForm.builder().title(expr-1)
{_F}.button1(expr-2).button2(expr-3)
return {_F}
expression [the] dropdown [component] display[s] %string% with [the] option[s] %strings%:
return type: strings
get:
set {_a::*} to expr-2
set {_s::1} to "dropdown"
set {_s::2} to expr-1
set {_s::3} to join {_a::*} by "[;;]"
return {_s::*}
expression [the] toggle [component] display[s] %string%[ with( | state )%-boolean%]:
return type: strings
get:
set {_s::1} to "toggle"
set {_s::2} to expr-1
if expr-2 is set:
set {_s::3} to "%expr-2%"
return {_s::*}
expression [the] input [component] display[s] %string% with placeholder %string% and (text|default text) %string%:
return type: strings
get:
set {_s::1} to "input"
set {_s::2} to expr-1
set {_s::3} to expr-2
set {_s::4} to expr-3
return {_s::*}
expression [the] slider component display[s] %string% with min[imum][ value] %number%(,| ,|, )max[imum][ value] %number%(,| ,|, )step %number%(,| ,|, )default [value ]%number%:
return type: strings
get:
set {_s::1} to "slider"
set {_s::2} to expr-1
set {_s::3} to "%expr-2%"
set {_s::4} to "%expr-3%"
set {_s::5} to "%expr-4%"
set {_s::6} to "%expr-5%"
return {_s::*}
effect send-form %object% with id %string% to %player%:
trigger:
set {_F} to expr-1.build()
if {_F}.getType() is FormType.SIMPLE_FORM:
set {_F} to LForm.SimpleListener(expr-3, expr-1, expr-2)
else if {_F}.getType() is FormType.MODAL_FORM:
set {_F} to LForm.ModalListener(expr-3, expr-1, expr-2)
else if {_F}.getType() is FormType.CUSTOM_FORM:
set {_F} to LForm.CustomListener(expr-3, expr-1, expr-2)
set {_fp} to FloodgateApi.getInstance().getPlayer(expr-3.getUniqueId())
{_fp}.sendForm({_F})
expression input component[ with] id %number% of %object%:
return type: string
get:
set {_r} to expr-2.getInput(expr-1)
return {_r}
expression toggle component[ with] id %number% of %object%:
return type: boolean
get:
set {_r} to expr-2.getToggle(expr-1)
return {_r}
expression slider component[ with] id %number% of %object%:
return type: number
get:
set {_r} to expr-2.getSlider(expr-1)
return {_r}
expression step slide[r] component[ with] id %number% of %object%:
return type: number
get:
set {_r} to expr-2.getStepSlide(expr-1)
return {_r}
expression dropdown component[ with] id %number% of %object%:
return type: number
get:
set {_r} to expr-2.getDropdown(expr-1)
return {_r}
expression component[ with] id %number% of %object%:
return type: string
get:
set {_t} to expr-2.getComponentTypes().toString().replaceAll("[\[\]]", "").split(",")
set {_t} to {_t}[expr-1]
if {_t} is "SLIDER":
set {_r} to expr-2.getSlider(expr-1)
else if {_t} is "STEP_SLIDER":
set {_r} to expr-2.getStepSlide(expr-1)
else if {t} is "TOGGLE":
set {_r} to expr-2.getToggle(expr-1)
else if {_t} is "DROPDOWN":
set {_r} to expr-2.getDropdown(expr-1)
else if {_t} is "INPUT":
set {_r} to expr-2.getInput(expr-1)
return "%{_r}%"
effect add %strings% to [form] %object%:
trigger:
set {_a::*} to expr-1
if {_a::1} is "dropdown":
set {_opt::*} to split {_a::3} by "[;;]"
expr-2.dropdown({_a::2}, [{_opt::*}])
else if {_a::1} is "input":
expr-2.input({_a::2}, {_a::3}, {_a::4})
else if {_a::1} is "toggle":
if {_a::3} is set:
set {_boolean} to {_a::3} parsed as boolean
else:
set {_boolean} to false
expr-2.toggle({_a::2}, {_boolean})
else if {_a::1} is "slider":
set {_min} to {_a::3} parsed as number
set {_max} to {_a::4} parsed as number
set {_step} to {_a::5} parsed as number
set {_default} to {_a::6} parsed as number
expr-2.slider({_a::2}, {_min}, {_max}, {_step}, {_default})
else:
set {_s::*} to split {_a::1} by "[;;]"
if {_s::1} is "url":
expr-2.button({_s::2}, Type.URL, {_s::3})
else if {_s::1} is "path":
expr-2.button({_s::2}, Type.PATH, {_s::3})
else if {_s::1} is "none":
expr-2.button({_s::2})
else if {_s::1} is "content":
expr-2.content({_s::2})
expression [the] [form] content %string%:
return type: string
get:
set {_b} to "content[;;]%expr-1%"
return {_b}
expression [the] button display %string%[ with (path icon %-string%|url icon %-string%)]:
return type: string
get:
if expr-2 is set:
set {_b} to "path[;;]%expr-1%[;;]%expr-2%"
else if expr-3 is set:
set {_b} to "url[;;]%expr-1%[;;]%expr-2%"
else:
set {_b} to "none[;;]%expr-1%"
return {_b}
#