- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Staff Pick: Kit System


By Mwthorn
Created: 2016/09/09 17:26:49 UTC-07:00 (7 years and 224 days ago)
Edited: 2016/09/09 17:28:17 UTC-07:00 (7 years and 224 days ago)
Likes: 1

Staff pick as of: 2016/09/11 02:38:22 UTC-07:00 (7 years and 222 days ago)
Denizen Version: 0.9.7 Build 1610
Script Version: 2
Description:

A kit system with a menu to show your status on your available kits.

Use "/kit" or "/kits" to open up your menu. You can also just type /kit (kit-name)" to get the kit specified.

Includes a config kit system for players to make their lives easier.
Also includes a sorting system to change the order for the items you get.

If you want to change the kits, look for the comment that says "Edit your kits below here"



Download script | View raw script
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
42500

KitSystem_Version:
    type: version
    name: KitSystem
    id: 108
    description: A kit system with a menu and config for all players.
    version: 2
    

KitSystem_Config:
    type: yaml data
    config:
        permission"essentials.kits.%kit%"
        default_order:
        - Sword
        - Bow
        - Rod
        - Gaps
        - Food
        - Armor
        - Arrow
        order_items:
            Sword'i@diamond_sword[display_name=&dSword]'
            Bow'i@bow[display_name=&dBow]'
            Rod'i@fishing_rod[display_name=&dRod]'
            Gaps'i@GOLDEN_APPLE[display_name=&dGaps;lore=&7May not be included in /kit pvp]'
            Food'i@cooked_beef[display_name=&dFood]'
            Armor'i@iron_chestplate[display_name=&dAll Armor;lore=&7Helmet|&7Chestplate|&7Leggings|&7Boots]'
            Arrow'i@arrow[display_name=&dArrows]'
        kits:
            # Edit your kits below here
            PvP:
                permission: essentials.kits.pvp
                cooldown: 10
                items:
                    Sword:
                    - i@diamond_sword
                    Bow:
                    - i@bow
                    Rod:
                    - i@fishing_rod
                    Gaps[]
                    Food:
                    - i@cooked_beef[quantity=16]
                    Armor:
                    - i@iron_helmet
                    - i@iron_chestplate
                    - i@iron_leggings
                    - i@iron_boots
                    Arrow:
                    - i@arrow[quantity=64]
            Master:
                permission: essentials.kits.master
                cooldown: 36000
                items:
                    Sword:
                    - i@diamond_sword[display_name=&aMaster;enchantments=DAMAGE_ALL,2|DURABILITY,1]
                    Bow:
                    - i@bow[display_name=&aMaster;enchantments=ARROW_DAMAGE,2|DURABILITY,1]
                    Rod:
                    - i@fishing_rod
                    Gaps:
                    - i@GOLDEN_APPLE[quantity=4]
                    Food:
                    - i@cooked_beef[quantity=16]
                    Armor:
                    - i@diamond_helmet[display_name=&aMaster;enchantments=PROTECTION_ENVIRONMENTAL,3]
                    - i@diamond_chestplate[display_name=&aMaster;enchantments=PROTECTION_ENVIRONMENTAL,2]
                    - i@diamond_leggings[display_name=&aMaster;enchantments=PROTECTION_ENVIRONMENTAL,2]
                    - i@diamond_boots[display_name=&aMaster;enchantments=PROTECTION_ENVIRONMENTAL,2]
                    Arrow:
                    - i@arrow[quantity=64]
            Master1:
                permission: essentials.kits.Master1
                cooldown: 10
                items:
                    Sword:
                    - i@diamond_sword
                    Bow:
                    - i@bow
                    Rod:
                    - i@fishing_rod
                    Gaps[]
                    Food:
                    - i@cooked_beef[quantity=16]
                    Armor:
                    - i@diamond_helmet
                    - i@iron_chestplate
                    - i@iron_leggings
                    - i@diamond_boots
                    Arrow:
                    - i@arrow[quantity=64]
            


                
KitSystem_Events:
    type: world
    debug: false
    events:
        # BC's data tracker.
        on system time hourly: 
        - webget "http://stats.denizenscript.com/tracker?script=<s@KitSystem_Version.yaml_key[id]>&version=<s@KitSystem_Version.yaml_key[version]>" 

        on player respawns:
        - if <player.has_flag[KitSystem_Status_AutoKit].not> {
            - wait 10t
            - if <player.is_online> {
                - if <player.has_permission[essentials.kits.master1].global> {
                    - execute as_player "kit master1"
                }
                else {
                    - execute as_player "kit pvp"
                }
            }
        }
        
        on player drags in KitSystem_OrderMenu:
        - determine cancelled
        
        on player clicks in KitSystem_OrderMenu:
        - determine cancelled passively
        - if <context.slot_type> == "CONTAINER" {
            - define order <s@KitSystem_Config.yaml_key[config.default_order]>
            - if <context.slot> <= <def[order].size> {
                - if <player.has_flag[KitSystem_SelectedItem]> {
                    - define slot1 <context.slot>
                    - define list <player.flag[KitSystem_sort_config]>
                    - define slot2 <player.flag[KitSystem_SelectedItem]>
                    - define new_list <def[list].set[<def[list].get[<def[slot2]>]>].at[<def[slot1]>]>
                    - define new_list <def[new_list].set[<def[list].get[<def[slot1]>]>].at[<def[slot2]>]>
                    - flag player KitSystem_sort_config:<def[new_list]>
                    - flag player KitSystem_SelectedItem:!
                    - flag server "KitSystem_Target_ConfigMenu:<player>"
                    - inject KitSystem_ConfigOrderPrepare
                }
                else {
                    - flag player KitSystem_SelectedItem:<context.slot>
                }
            }
        }
        
        on player drags in KitSystem_KitsMenu:
        - determine cancelled
        
        on player clicks in KitSystem_KitsMenu:
        - determine cancelled passively
        - if <context.item.display_name.strip_color.starts_with[Kit<&co>].not||true> {
            - if <context.item.scriptname||null> == "KitSystem_KitConfigItem" {
                - execute as_player "kitconfig"
            }
            - queue clear
        }
        - inventory close d:<context.inventory>
        - define title <context.item.display_name.strip_color.after[Kit<&co><&sp>]||null>
        - if <def[title]> == null {
            - queue clear
        }
        - execute as_player "kit <def[title]>"
    
        on player clicks KitSystem_ConfigItem1 in KitSystem_ConfigMenu:
        - determine cancelled passively
        - flag server "KitSystem_Target_ConfigMenu:<player>"
        - inject KitSystem_ConfigOrderPrepare
    
        on player clicks KitSystem_ConfigItem2 in KitSystem_ConfigMenu:
        - determine cancelled passively
        - if <player.has_Flag[KitSystem_Status_AutoKit]> {
            - flag player KitSystem_Status_AutoKit:!
        }
        else {
            - flag player KitSystem_Status_AutoKit
        }
        - flag server "KitSystem_Target_ConfigMenu:<player>"
        - inventory open d:in@KitSystem_ConfigMenu
        
        on player clicks KitSystem_ConfigItem3 in KitSystem_ConfigMenu:
        - determine cancelled passively
        - if <player.has_Flag[KitSystem_Status_AutoArmor]> {
            - flag player KitSystem_Status_AutoArmor:!
        }
        else {
            - flag player KitSystem_Status_AutoArmor
        }
        - flag server "KitSystem_Target_ConfigMenu:<player>"
        - inventory open d:in@KitSystem_ConfigMenu
                
KitSystem_Command:
    type: command
    name: kit
    description: Kit command to your kits
    debug: false
    usage: /kit
    aliases:
    - kits
    script:
    - if <context.args.size> >= 1 {
        - define kit <context.args.get[1]||pvp>
        - if <s@KitSystem_Config.list_keys[config.kits].contains[<def[kit]>]||false> {
            - define permission <s@KitSystem_Config.yaml_key[config.kits.<def[kit]>.permission]>
            - if <player.has_permission[<def[permission]>].global.not||true> {
                - narrate  "<&c>No acccess to that kit!"
                - queue clear
            }
            - define cd_flag KitSystem_Cooldown_<def[kit]>
            - if <player.has_flag[<def[cd_flag]>]||true> {
                - narrate "<&7>The kit <&c><def[kit]> <&7>can be taken at <&c><player.flag[<def[cd_flag]>].expiration.formatted>"
                - queue clear
            }
            - narrate "<&3>Giving kit<&co> <&6><&l><def[kit]>"
            - if <player.has_flag[KitSystem_Notify_Cooldown].not> {
                - flag player KitSystem_Notify_Cooldown duration:30m
                - narrate "<&a>/kitconfig <&3>to change the order of your kit!"
            }
            - define itemtypes <s@KitSystem_Config.list_keys[config.kits.<def[kit]>.items]||i@dirt>
            - define cooldown <s@KitSystem_Config.yaml_key[config.kits.<def[kit]>.cooldown]||10>
            - if <player.has_flag[KitSystem_sort_config].not> {
                - define order <s@KitSystem_Config.yaml_key[config.default_order]>
                - flag player "KitSystem_sort_config:<def[order]>"
            }
            - foreach <player.flag[KitSystem_sort_config]> {
                - define items <s@KitSystem_Config.yaml_key[config.kits.<def[kit]>.items.<def[value]>]>
                - if <def[items].is_empty.not> {
                    - if <def[value]> == "Armor" {
                        - if <player.has_flag[KitSystem_Status_AutoArmor].not> {
                            - if <player.equipment> == "li@i@air|i@air|i@air|i@air" {
                                - adjust <player> equipment:<s@KitSystem_Config.yaml_key[config.kits.<def[kit]>.items.<def[value]>].parse_color.as_list.reverse>
                            }
                            else {
                                - give <s@KitSystem_Config.yaml_key[config.kits.<def[kit]>.items.<def[value]>].parse_color>
                            }
                        }
                        else {
                            - give <s@KitSystem_Config.yaml_key[config.kits.<def[kit]>.items.<def[value]>].parse_color>
                        }
                    }
                    else {
                        - give <s@KitSystem_Config.yaml_key[config.kits.<def[kit]>.items.<def[value]>].parse_color>
                    }
                }
            }
            - if <player.is_op.not> {
                - flag player "<def[cd_flag]>" "duration:<def[cooldown]>s"
            }
            - queue clear
        }
        else {
            - narrate "<&c>That kit does not exist..."
        }
    }
    else {
        - flag server "KitSystem_Target_KitsMenu:<player>"
        - inventory open d:in@KitSystem_KitsMenu
    }
    
KitSystem_KitsMenu:
  type: inventory
  debug: false
  inventory: CHEST
  title<&8>Kits Menu
  size: 27
  definitions:
    Item1<proc[KitSystem_KitsMenu_Proc].context[1|PvP]>[display_name=<proc[KitSystem_KitsMenu_Proc].context[2|PvP]>;lore=<proc[KitSystem_KitsMenu_Proc].context[3|PvP]>]
    Item2<proc[KitSystem_KitsMenu_Proc].context[1|Master]>[display_name=<proc[KitSystem_KitsMenu_Proc].context[2|Master]>;lore=<proc[KitSystem_KitsMenu_Proc].context[3|Master]>]
    Item3<proc[KitSystem_KitsMenu_Proc].context[1|Master1]>[display_name=<proc[KitSystem_KitsMenu_Proc].context[2|Master1]>;lore=<proc[KitSystem_KitsMenu_Proc].context[3|Master1]>]
    Config: KitSystem_KitConfigItem
    P: STAINED_GLASS_PANE,7
  slots:
    - "[Config] [P] [P] [item1] [item2] [item3] [P] [P] [Config]"

    
KitSystem_KitsMenu_Proc:
    type: procedure
    debug: false
    definitions: line|item
    script:
    - define target <server.flag[KitSystem_Target_KitsMenu]>
    - define permission <s@KitSystem_Config.yaml_key[config.kits.<def[item]>.permission]>
    - define access <def[target].has_permission[<def[permission]>]>
    - choose "<def[line]>":
        - case "1":
            - define cd_flag KitSystem_Cooldown_<def[item]>
            - if <def[access]> {
                - if <def[target].has_flag[<def[cd_flag]>]> {
                    - determine "STAINED_GLASS_PANE,4"
                }
                else {
                    - determine "STAINED_GLASS_PANE,5"
                }
            }
            else {
                - determine "STAINED_GLASS_PANE,14"
            }
        - case "2":
            - determine "<&6><&l>Kit<&co> <def[item]>"
        - case "3":
            - define cd_flag KitSystem_Cooldown_<def[item]>
            - if <def[access]> {
                - if <def[target].has_flag[<def[cd_flag]>]> {
                    - determine "<&e>Can be taken in <&b><def[target].flag[<def[cd_flag]>].expiration.formatted>"
                }
                else {
                    - determine "<&a>Ready!"
                }
            }
            else {
                - determine "<&c>No Access!"
            }
        - default:
            - determine "Chosen default in <def[item]>"


KitSystem_KitConfigItem:
    type: item
    debug: false
    material: ENDER_CHEST
    display name<&d>KitConfig
    lore:
    - <&9>Order, automatic kits, etc.
            
KitSystem_ConfigCommand:
    type: command
    name: kitconfig
    description: Kit command for your kits
    debug: false
    usage: /kitconfig
    script:
    - flag server "KitSystem_Target_ConfigMenu:<player>"
    - inventory open d:in@KitSystem_ConfigMenu
    
KitSystem_ConfigOrderPrepare:
    type: task
    script:
    - if <player.has_flag[KitSystem_sort_config].not> {
        - define order <s@KitSystem_Config.yaml_key[config.default_order]>
        - flag player "KitSystem_sort_config:<def[order]>"
    }
    - inventory open d:in@KitSystem_OrderMenu
    
KitSystem_ConfigMenu: 
  type: inventory 
  debug: false
  inventory: CHEST
  title<&6>Kit Config
  size: 9
  definitions: 
    Item1: i@KitSystem_ConfigItem1
    Item2: i@KitSystem_ConfigItem2
    Item3: i@KitSystem_ConfigItem3
    P: STAINED_GLASS_PANE,7
  slots: 
    - "[] [] [Item1] [] [Item2] [] [Item3] [] []"
    
    
KitSystem_ConfigItem1:
    type: item
    material: CHEST
    display name<&d>Kit Order
    lore:
    - <&3>Here you can change the order
    - <&3>when you get your kit.
    
KitSystem_ConfigItem2:
    type: item
    debug: false
    material: IRON_SWORD
    display name<&d>Auto-Kit
    lore:
    - <&9>Status<&co> <proc[KitSystem_ConfigMenu_Proc].context[AutoKit]>
    - <&3>When you respawn, your kit
    - <&3>will be automatic given 
    - <&3>if not on cooldown.
  
KitSystem_ConfigItem3:
    type: item
    debug: false
    material: Iron_Chestplate
    display name<&d>Auto-Armor
    lore:
    - <&9>Status<&co> <proc[KitSystem_ConfigMenu_Proc].context[AutoArmor]>
    - <&3>Your armor is equipped instead
    - <&3>of being filled in your inventory.
    - <&3>This only happens when you take your kit.

KitSystem_ConfigMenu_Proc:
    type: procedure
    debug: false
    definitions: item
    script:
    - define target <server.flag[KitSystem_Target_ConfigMenu]>
    - define status_flag KitSystem_Status_<def[item]>
    - if <def[target].has_flag[<def[status_flag]>]> {
        - determine "<&c>Turned Off"
    }
    else {
        - determine "<&a>Turned On"
    }
KitSystem_OrderMenu:
  type: inventory
  debug: false
  inventory: CHEST
  title<&8>Click on 2 items to swap.
  size: 9
  definitions:
    Item1<proc[KitSystem_OrderMenu_Proc].context[1]>
    Item2<proc[KitSystem_OrderMenu_Proc].context[2]>
    Item3<proc[KitSystem_OrderMenu_Proc].context[3]>
    Item4<proc[KitSystem_OrderMenu_Proc].context[4]>
    Item5<proc[KitSystem_OrderMenu_Proc].context[5]>
    Item6<proc[KitSystem_OrderMenu_Proc].context[6]>
    Item7<proc[KitSystem_OrderMenu_Proc].context[7]>
    Item8<proc[KitSystem_OrderMenu_Proc].context[8]>
    Item9<proc[KitSystem_OrderMenu_Proc].context[9]>
  slots:
    - "[Item1] [Item2] [Item3] [Item4] [Item5] [Item6] [Item7] [Item8] [Item9]"

KitSystem_OrderMenu_Proc:
    type: procedure
    debug: false
    definitions: item
    script:
    - define target <server.flag[KitSystem_Target_ConfigMenu]>
    - define item <def[target].flag[KitSystem_sort_config].after[li@].split[|].get[<def[item]>]||null>
    - determine <s@KitSystem_Config.yaml_key[config.order_items.<def[item]>].parse_color||i@air>






View History