-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
notebook.sk
303 lines (235 loc) · 10.7 KB
/
notebook.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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
options:
debug: false
codes: 0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|k|l|m|n|o|r
function removeColor(msg: text) :: text:
set {_m::*} to {_msg} split at ""
set {_color-codes} to "{@codes}"
set {_colors::*} to {_color-codes} split at "|"
set {_new} to ""
loop {_m::*}:
set {_char} to loop-value
set {_prev} to the last character of {_new}
if {_prev} is "&":
loop {_colors::*}:
if loop-value-2 is {_char}:
set {_skip} to true
if {_skip} is set:
delete {_skip}
else:
set {_new} to "%{_new}%%{_char}%"
return {_new}
function jsonColorize(msg: text, default-color: text = "&r") :: text:
set {_m::*} to {_msg} split at ""
set {_color-codes} to "{@codes}"
set {_colors::*} to {_color-codes} split at "|"
set {_color} to colored {_default-color}
set {_code} to the first character of {_color}
set {_new} to ""
set {_skip} to 0
loop amount of {_m::*} times:
if {_skip} is more than or equal to 1:
subtract 1 from {_skip}
else:
set {_char} to {_m::%loop-number%}
set {_next} to {_m::%loop-number + 1%}
if {_char} is "&" or {_code}:
loop {_colors::*}:
if loop-value-2 is {_next}:
set {_color} to "%{_color}%%{_code}%%{_next}%"
if {_next} is "r":
set {_color} to {_default-color}
set {_new} to "%{_new}%%{_color}%"
set {_skip} to 1
if {_skip} is less than or equal to 0:
set {_new} to "%{_new}%%{_char}%"
else if {_char} is " ":
set {_new} to "%{_new}% %{_color}%"
else:
set {_new} to "%{_new}%%{_char}%"
return {_new}
function jsonSanitize(msg: text) :: text:
set {_m::*} to {_msg} split at ""
loop {_m::*}:
if loop-value is """":
set {_m::%loop-index%} to "\""" # """
else if loop-value is "\":
set {_m::%loop-index%} to "\\"
set {_new} to join {_m::*} with ""
return {_new}
function jsonFormat(msg: text, color: boolean = true) :: text:
set {_m::*} to {_msg} split at "||"
set {_current} to 1
loop {_m::*}:
if {_clusters::%{_current}%} is not set:
set {_clusters::%{_current}%} to ""
if {_clusters::%{_current}%::text} is not set:
set {_clusters::%{_current}%::text} to jsonSanitize(loop-value)
else:
set {_tag} to the first 4 characters of loop-value
set {_value} to subtext of loop-value from characters 5 to the length of loop-value
if {_tag} is "ttp:":
set {_clusters::%{_current}%::tooltip} to jsonSanitize({_value})
else if {_tag} is "cmd:":
set {_clusters::%{_current}%::command} to jsonSanitize({_value})
else if {_tag} is "sgt:":
set {_clusters::%{_current}%::suggest} to jsonSanitize({_value})
else if {_tag} is "url:":
if {_value} doesn't contain "http://" or "https://":
set {_value} to "http://%{_value}%"
set {_clusters::%{_current}%::url} to jsonSanitize({_value})
else if {_tag} is "ins:":
set {_clusters::%{_current}%::insertion} to jsonSanitize({_value})
else:
add 1 to {_current}
set {_clusters::%{_current}%::text} to jsonSanitize(loop-value)
set {_clusters::%{_current}%} to ""
loop {_clusters::*}:
set {_i} to loop-index
set {_text} to {_clusters::%{_i}%::text}
if {_color} is true:
set {_text} to jsonColorize({_text})
if {_json} is not set:
set {_json} to "{""text"":""%{_text}%"""
else:
set {_json} to "%{_json}%,{""text"":""%{_text}%"""
if {_clusters::%{_i}%::tooltip} is set:
if {_color} is true:
set {_tooltip} to jsonColorize({_clusters::%{_i}%::tooltip})
else:
set {_tooltip} to {_clusters::%{_i}%::tooltip}
set {_json} to "%{_json}%,""hoverEvent"":{""action"": ""show_text"",""value"": ""%{_tooltip}%""}"
if {_clusters::%{_i}%::insertion} is set:
set {_json} to "%{_json}%,""insertion"":""%{_clusters::%{_i}%::insertion}%"",""obfuscated"":false"
if {_clusters::%{_i}%::command} is set:
set {_clickable} to "%{_json}%,""clickEvent"":{""action"":""run_command"",""value"":""%{_clusters::%{_i}%::command}%""}"
if {_clusters::%{_i}%::suggest} is set:
set {_clickable} to "%{_json}%,""clickEvent"":{""action"": ""suggest_command"",""value"": ""%{_clusters::%{_i}%::suggest}%""}"
if {_clusters::%{_i}%::url} is set:
set {_clickable} to "%{_json}%,""clickEvent"":{""action"": ""open_url"",""value"": ""%{_clusters::%{_i}%::url}%""}"
if {_clickable} is set:
set {_json} to "%{_clickable}%}"
delete {_clickable}
else:
set {_json} to "%{_json}%}"
return "{""text"":"""", ""extra"":[%{_json}%]}"
function json(to: text, msg: text, color: boolean = true):
set {_msg} to jsonFormat({_msg}, {_color})
execute console command "/tellraw %{_to}% %{_msg}%"
# Name: SkNotepad
# Author: TrueFusion
# Version: 1.0
# Dependancies: Skript, Json.sk
# Use: A Chat Notepad For Servers.
command /notepad [<text>]:
description: Toggles on and off the Notepad.
permission: notepad.use
permission message: &a&lNotepad &7| &fYou do not have the correct permissions!
trigger:
if arg-1 is "on":
set {notepad.toggle.%player's uuid%} to true
send "&a&lNotepad &7| &fThe Notepad is now on!"
if {notepad.%player's uuid%::*} is not set:
set {_uuid} to player's uuid
delete {notepad.%{_uuid}%::*}
set {_x} to 101
loop 94 times:
remove 1 from {_x}
if {notepad.%{_uuid}%::%{_x}%} is not set:
set {notepad.%{_uuid}%::%{_x}%} to ""
set {notepad.%{_uuid}%::6} to "&8&l------------------------------"
set {notepad.%{_uuid}%::5} to "&8&l|"
set {notepad.%{_uuid}%::4} to "&8&l|"
set {notepad.%{_uuid}%::3} to "&8&l|"
set {notepad.%{_uuid}%::2} to "&8&l|"
set {notepad.%{_uuid}%::1} to "&8&l------------------------------"
else if arg-1 is "off":
if {notepad.toggle.%player's uuid%} is true:
loop 100 times:
send "" to player
set {notepad.toggle.%player's uuid%} to false
send "&a&lNotepad &7| &fThe Notepad is now off!"
else:
set {notepad.toggle.%player's uuid%} to false
send "&a&lNotepad &7| &fThe Notepad is now off!"
else:
send "&a&lNotepad &7| &f/notepad (on/off)" to player
on chat:
if {notepad.toggle.%sender's uuid%} is true:
cancel event
notepadCycle(sender)
set {notepad.%sender's uuid%::7} to message
set {_c} to 101
loop 100 times:
send "" to sender
loop 100 times:
remove 1 from {_c}
if {notepad.%sender's uuid%::%{_c}%} is not "":
if {_c} is not less than 7:
send "&7&l%({_c} - 6)% &r&f%{notepad.%sender's uuid%::%{_c}%}%" to sender
else:
if {_c} is 6:
json("%sender%", "&8&l------------------------------")
if {_c} is 5:
json("%sender%", "&8&l|&r||&f ||&c&lExit||ttp:&7Save and exit notepad||cmd:/notepad off")
if {_c} is 4:
json("%sender%", "&8&l|&r||&f ||&4&lReset||ttp:&7Reset your notepad||cmd:/notepad:reset")
if {_c} is 3:
json("%sender%", "&8&l|&r||&f ||&a&lVersion||ttp:&a&lNotepad &7| &fV1.0")
if {_c} is 2:
json("%sender%", "&8&l|&r||&f ||&b&l%sender%||ttp:&7Its you!")
if {_c} is 1:
json("%sender%", "&8&l------------------------------")
every 5 ticks:
loop all players:
if {notepad.toggle.%loop-player's uuid%} is true:
set {_c} to 101
loop 100 times:
send "" to loop-player
loop 100 times:
remove 1 from {_c}
if {notepad.%loop-player's uuid%::%{_c}%} is not "":
if {_c} is not less than 7:
send "&7&l%({_c} - 6)% &r&f%{notepad.%loop-player's uuid%::%{_c}%}%" to loop-player
else:
if {_c} is 6:
json("%loop-player%", "&8&l------------------------------")
if {_c} is 5:
json("%loop-player%", "&8&l|&r||&f ||&c&lExit||ttp:&7Save and exit notepad||cmd:/notepad off")
if {_c} is 4:
json("%loop-player%", "&8&l|&r||&f ||&4&lReset||ttp:&7Reset your notepad||cmd:/notepad:reset")
if {_c} is 3:
json("%loop-player%", "&8&l|&r||&f ||&a&lVersion||ttp:&a&lNotepad &7| &fV1.0")
if {_c} is 2:
json("%loop-player%", "&8&l|&r||&f ||&b&l%loop-player%||ttp:&7Its you!")
if {_c} is 1:
json("%loop-player%", "&8&l------------------------------")
else if {notepad.%loop-player's uuid%::%{_c}%} is not set:
set {notepad.%loop-player's uuid%::%{_c}%} to ""
command /notepad:reset:
description: Resets the notepad!
permission: notepad.use
permission message: &a&lNotepad &7| &fYou do not have the correct permissions!
trigger:
set {_uuid} to player's uuid
delete {notepad.%{_uuid}%::*}
set {_x} to 101
loop 94 times:
remove 1 from {_x}
if {notepad.%{_uuid}%::%{_x}%} is not set:
set {notepad.%{_uuid}%::%{_x}%} to ""
set {notepad.%{_uuid}%::6} to "&8&l------------------------------"
set {notepad.%{_uuid}%::5} to "&8&l|"
set {notepad.%{_uuid}%::4} to "&8&l|"
set {notepad.%{_uuid}%::3} to "&8&l|"
set {notepad.%{_uuid}%::2} to "&8&l|"
set {notepad.%{_uuid}%::1} to "&8&l------------------------------"
function notepadCycle(p: player):
set {_uuid} to {_p}'s uuid
set {_c} to 101
set {_x} to 100
loop 93 times:
remove 1 from {_c}
remove 1 from {_x}
if {notepad.%{_uuid}%::%{_x}%} is not set:
set {notepad.%{_uuid}%::%{_x}%} to ""
set {notepad.%{_uuid}%::%{_c}%} to {notepad.%{_uuid}%::%{_x}%}