Paste #44127: Untitled Paste

Date: 2017/09/04 10:11:40 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


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
426
427
428
429
430
431


#######################################################
##                 Nations Command                   ##
####################################################### 
NATIONS_FILE_LOADER: 
    type: world 
    debug: false 
    events: 
        on server start: 
        - foreach <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst> {  
            - yaml "load:dNations/<def[value]>.yml" id:<def[value]> 
            } 
       # on system time minutely command: 
        #- foreach <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst> {  
         #   - yaml "load:dNations/<def[value]>.yml" id:<def[value]> 
          #  } 

NATIONS_COMMAND: 
    type: command 
    name: nation 
    aliases: 
    - n 
    - nations 
    script: 
    - choose "<context.args.get[1]>": 
        - case "setup": 
            - foreach <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst> { 
                - if !<server.has_file[<def[value]>]> { 
                    - yaml create id:<def[value]> 
                    - yaml "savefile:dNations/<def[value]>.yml" id:<def[value]> 
                    } 
                } 
        - case "apply": 
            - if <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst.contains[<context.args.get[2]>]> { 
                - yaml id:<context.args.get[2]> set pending_apps.<player.name>:true
                - yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>
                - narrate "<&a>Your app has been sent!" 
                } 
        - case "apps": 
            - if <player.flag[rank]> == "leader" {  
                - if <yaml[<player.flag[nation]>].read[pending_apps]||null> != null {
                    - inject dNations_Apps 
                        } 
                else {  
                  - narrate "<&c>You have no pending applications!" 
                } 
                    } 
            else {  
              - narrate "<&c>You do not have permission to check nation apps!" 
            }
        - case "leave":
            - if <player.has_flag[leaving_nation]> {
                - narrate "<&c>You have left the nation!"
                - flag <player> nation:!
                - flag <player> leaving_nation:!
                - yaml id:<player.flag[nation]> set members:->:<context.args.get[2]>:!
            }
            else {
                - narrate "<&c>You are leaving your nation!"
                - narrate "<&c>Type /nation leave within 10 seconds to confirm!"
                - flag <player> leaving_nation duration:10
            }
            - wait 11s
            - if <player.has_flag[leaving_nation]> {
                - narrate "<&a>You have chosen to stay."
                - flag <player> leaving_nation:!
            }
        - case "banish":
            - if <player.flag[rank]> == "leader" {
                - if <server.list_players.contains[<context.args.get[2]>]> {
                    - if <player.has_flag[banishing_<context.args.get[2]>]> {
                        - narrate "<&c><context.args.get[2]> has been banished!"
                        - flag <context.args.get[2]> nation:!
                        - yaml id:<player.flag[nation]> set members:->:<context.args.get[2]>:!
                        - flag <player> banishing_<context.args.get[2]>:!
                    }
                    else {
                        - narrate "<&c>Are you sure you want to banish <context.args.get[2]>?"
                        - narrate "<&c>Type /nation banish <player> within 10 seconds to confirm!"
                        - flag <player> banishing_<context.args.get[2]> duration:10
                    }
                    - wait 11s
                    - if <player.has_flag[banishing_<context.args.get[2]>]> {
                        - narrate "<&a>You have been merciful."
                        - flag <player> banishing_<context.args.get[2]>:!
                    }
                    else {
                        - narrate "<&c>That is not a valid player!"
                    }
                }
            else {
                - narrate "<&c>Only nation leaders can banish players!"
            }
        - case "info":
            - choose "<context.args.size>":
                - case "2":
                    - if <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst.contains[<context.args.get[2]>]> {
                        - narrate "<&5>------------------------"
                        - narrate "<&d>  The <context.args.get[2]>'s Info" 
                        - narrate "<&5>------------------------"
                        - narrate "<&5>ID: <&d><context.args.get[2]>"
                        - narrate "<&5>Members: <&d><yaml[<context.args.get[2]>].read[members].formatted>"
                        - narrate "<&5>Claimed Chunks: <&d><yaml[<context.args.get[2]>].read[claimed_chunks].size>"
                        - narrate "<&5>Enemies: <&d><yaml[<context.args.get[2]>].read[enemies].formatted>"
                        - narrate "<&5>Money: <&d><yaml[<context.args.get[2]>].read[money]>"
                        - narrate "<&5>Power: <&d><yaml[<context.args.get[2]>].read[power]>"
                    }
                    else {
                        - narrate "<&c>That is not a valid dNation!"
                    }
                - default:
                    - narrate "<&5>------------------------"
                    - narrate "<&d>  The <player.flag[nation]>'s Info" 
                    - narrate "<&5>------------------------"
                    - narrate "<&5>ID: <&d><player.flag[nation]>"
                    - narrate "<&5>Members: <&d><yaml[<player.flag[nation]>].read[members].formatted>"
                    - narrate "<&5>Claimed Chunks: <&d><yaml[<player.flag[nation]>].read[claimed_chunks].size>"
                    - narrate "<&5>Enemies: <&d><yaml[<player.flag[nation]>].read[enemies].formatted>"
                    - narrate "<&5>Money: <&d><yaml[<player.flag[nation]>].read[money]>"
                    - narrate "<&5>Power: <&d><yaml[<player.flag[nation]>].read[power]>"
        - case "help":
            - narrate "<&5>--------------------"
            - narrate "<&d>  dNations  by Kaiyoko" 
            - narrate "<&5>--------------------"
            - narrate "<&5>/nation apply <nation>: <&d>Apply for a nation."
            - narrate "<&5>/nation leave: <&d>Abandon a nation."
            - narrate "<&5>/nation info [nation]: Display info about a nation."
            - if <player.flag[rank]> == leader {
                - narrate "<&5>/nation apps: <&d>List all pending applications for your nation."
                - narrate "<&5>/nation banish <&lt>player<&gt>: <&d>Banish a player from your nation."
                - narrate "<&5>/nation claim: <&d>Claim the chunk you're standing in."
                - narrate "<&5>/nation war <&lt>nation ID<&gt>: <&d>Declare war on a nation."
            }
            - narrate "<&7>Use /nation help <command> to view more info on that command."
        - case "war":
            - if <player.flag[rank] == leader> {
                - if <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst.exclude[<player.flag[nation]>].contains[<context.args.get[2]> {
                    - narrate "<&c>You have declared war on the <context.args.get[2]>"
                    - yaml id:<player.flag[nation]> set enemies.<context.args.get[2]>
                }        
                else {
                    - narrate "<&c>That is not a valid nation!"
                }
            }
            else {
                - narrate "<&c>Only nation leaders can declare war!"
            }
        - case "claim": 
            - if <player.flag[rank]> == leader { 
                - define unclaimed true 
                - foreach <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst> { 
                    - if <yaml[<def[value]>].read[claimed_chunks].contains[<player.location.chunk>]> && <yaml[<def[value]>].read[power]> > <yaml[<player.flag[nation]>].read[power]> && !<yaml[<player.flag[nation]>].read[enemies].contains[<def[value]>]> { 
                        - define unclaimed false 
                        - narrate "<&c>This chunk has been claimed by <def[value]>. You may not claim it." 
                        - break 
                    } 
                } 
                if <def[unclaimed]> { 
                    - narrate "<&a>Chunk is unclaimed. Adding it to this nation's territory." 
                    - yaml id:<player.flag[nation]> set claimed_chunks:->:<player.location.chunk> 
                } 
            } 
            else { 
               - narrate "<&c>Only nation leaders can claim land!" 
        - default: 
            - narrate "<&c>Unknown nation command! Use /nation help to view a full command list."

dNations_Apps: 
    type: task 
    script: 
    - choose "<context.args.size>": 
        - case "2": 
            - if <yaml[<player.flag[nation]>].list_keys[pending_apps].contains[<context.args.get[2]>]> { 
                - narrate "<&5>-------------------------" 
                - narrate "<&d>   <context.args.get[2]>'s Application"  
                - narrate "<&5>-------------------------" 
                - narrate "<&5>Character: <&d><server.match_offline_player[<context.args.get[2]>].flag[charname]>" 
                - narrate "<&5>Gender: <&d><player.flag[gender]||Genderless>" 
                - narrate "<&5>Element: <&d><player.flag[element]>" 
                - narrate "<&5>Joined at: <&d><player.flag[jointime]> on <player.flag[joindate]>" 
                - narrate "<&5>Last Seen at: <&d><player.flag[seentime]> on <player.flag[seendate]>" 
            } 
            else { 
                - narrate "<&c>You do not have a pending app from that player!" 
            } 
        - case "3": 
            - choose <context.args.get[3]>: 
                - case "accept": 
                    - yaml id:<player.flag[nation]> set pending_apps.<context.args.get[2]>:!
                    - yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>                    
                    - flag <context.args.get[2]> nation:<player.flag[nation]> 
                    - yaml id:<player.flag[nation]> set members:->:<context.args.get[2]>
                    - execute as_player "mail send <context.args.get[2]> Your app has been Accepted!" 
                - case "deny": 
                    - yaml id:<player.flag[nation]> set pending_apps.<context.args.get[2]>:!
                    - yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>
                    - execute as_player "mail send <context.args.get[2]> Your app has been Rejected!" 
                - default: 
                    - narrate "<&c>That is not a valid dNations apps command!" 
        - default: 
            - narrate "<&5>You have pending apps from:" 
            - foreach <yaml[<player.flag[nation]>].list_keys[pending_apps]> {  
                - narrate "<&d>- <def[value]>" 
            } 


#######################################################
##                  Ledger Inventories               ##
####################################################### 

LEDGER_TRIGGER:
    type: world
    events:
        on player right clicks enchantment_table:
        - determine passively cancelled
        - inventory open d:in@LEDGER

LEDGER:
    type: inventory
    title: Nation Ledger
    size: 27
    slots:
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE]"
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@CHECKBUDGET_ITEM] [i@VAULT_ITEM] [i@CSALARIES_ITEM] [i@SENDMONEY_ITEM] [i@ICTRADE_ITEM] [i@NOTHING_HERE] [i@NOTHING_HERE]"
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@EXIT]"

LEDGER_HANDLER:
    type: world
    events:
            on player clicks in LEDGER:
            - determine cancelled
            on player drags in LEDGER:
            - determine cancelled
            on player clicks EXIT in LEDGER:
            - inventory close
            on player clicks CHECKBUDGET_ITEM in LEDGER:
            - inventory open d:in@CHECKBUDGET
            on player clicks VAULT_ITEM in LEDGER:
            - inventory open d:in@VAULT
            on player clicks CSALARIES_ITEM in LEDGER:
            - inventory open d:in@CSALARIES
            on player clicks SENDMONEY_ITEM in LEDGER:
            - inventory open d:in@SENDMONEY
            on player clicks ICTRADE_ITEM in LEDGER:
            - inventory open d:in@ICTRADE

CHECKBUDGET:
    type: inventory
    title: Check your nation's budget!
    size: 27
    slots:
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE]"
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@CHECKBUDGET_ITEM] [i@VAULT_ITEM] [i@CSALARIES_ITEM] [i@SENDMONEY_ITEM] [i@ICTRADE_ITEM] [i@NOTHING_HERE] [i@NOTHING_HERE]"
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@EXIT]"

CHECKBUDGET_HANDLER:
    type: world
    events:
            on player clicks in CHECKBUDGET:
            - determine cancelled
            on player drags in CHECKBUDGET:
            - determine cancelled
            on player clicks EXIT in CHECKBUDGET:
            - inventory close
            on player clicks CHECKBUDGET_ITEM in CHECKBUDGET:
            - inventory open d:in@CHECKBUDGET
            on player clicks VAULT_ITEM in CHECKBUDGET:
            - inventory open d:in@VAULT
            on player clicks CSALARIES_ITEM in CHECKBUDGET:
            - inventory open d:in@CSALARIES
            on player clicks SENDMONEY_ITEM in CHECKBUDGET:
            - inventory open d:in@SENDMONEY
            on player clicks ICTRADE_ITEM in CHECKBUDGET:
            - inventory open d:in@ICTRADE

VAULT:
    type: inventory
    title: Your Nation's Vault!
    size: 27
    slots:
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE]"
    - "[i@NOTHING_HERE] [i@WITHDRAW_HUNDRED_WUN] [i@WITHDRAW_TEN_WUN] [i@WITHDRAW_ONE_WUN] [i@BALANCE_ITEM] [i@DEPOSIT_ONE_WUN] [i@DEPOSIT_TEN_WUN] [i@DEPOSIT_HUNDRED_WUN] [i@NOTHING_HERE]"
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@EXIT]"

VAULT_HANDLER:
    type: world
    events:
            on player clicks in VAULT:
            - determine cancelled
            on player drags in VAULT:
            - determine cancelled
            on player clicks EXIT in VAULT:
            - inventory close
            on player clicks WITHDRAW_HUNDRED_WUN in VAULT:
            - flag <player> money:<player.flag[money].sub[100]>
            - give HUNDRED_WUN
            on player clicks WITHDRAW_TEN_WUN in VAULT:
            - flag <player> money:<player.flag[money].sub[10]>
            - give TEN_WUN
            on player clicks WITHDRAW_ONE_WUN in VAULT:
            - flag <player> money:<player.flag[money].sub[1]>
            - give ONE_WUN
            on player clicks DEPOSIT_HUNDRED_WUN in VAULT:
            - take HUNDRED_WUN from:<player.inventory>
            - flag <player> money:<player.flag[money].add[100]>
            on player clicks DEPOSIT_TEN_WUN in VAULT:
            - take TEN_WUN from:<player.inventory>
            - flag <player> money:<player.flag[money].add[10]>
            on player clicks DEPOSIT_ONE_WUN in VAULT:
            - take ONE_WUN from:<player.inventory>
            - flag <player> money:<player.flag[money].add[1]>

#######################################################
##                     dItems                        ##
####################################################### 

CHECKBUDGET_ITEM:
    type: item
    material: i@gold_nugget
    display name: <&6>Check Budget
    lore:
    - <&e><&o>Money comes in, money goes out. See where it all ends up!

VAULT_ITEM:
    type: item
    material: i@dispenser
    display name: <&6>Vault
    lore:
    - <&e><&o>Your Nation's personal savings!

CSALARIES_ITEM:
    type: item
    material: i@book_and_quill
    display name: <&6>Citizen Salaries
    lore:
    - <&e><&o>No slavery here!

SENDMONEY_ITEM:
    type: item
    material: i@gold_ingot
    display name: <&6>Send Money
    lore:
    - <&e><&o>Feeling generous?

ICTRADE_ITEM:
    type: item
    material: i@empty_map
    display name: <&6>International Trade
    lore:
    - <&e><&o>Did you lose a war? Or are you simply feeling benevolent?

NOTHING_HERE:
    type: item
    material: i@gray_stained_glass_pane
    display name:   

BALANCE_ITEM:
    type: item
    material: i@nether_star
    display name: <&6>Balance
    lore:
    - "<&e><player.flag[money] Wun"

WITHDRAW_ONE_WUN:
    type: item
    material: i@gold_nugget
    display name: <&6>-1
    lore:
    - <&e>Withdraw 1 Wun

WITHDRAW_TEN_WUN:
    type: item
    material: i@gold_ingot
    display name: <&6>-10
    lore:
    - <&e>Withdraw 10 Wun

WITHDRAW_HUNDRED_WUN:
    type: item
    material: i@gold_block
    display name: <&6>-100
    lore:
    - <&e>Withdraw 100 Wun

DEPOSIT_ONE_WUN:
    type: item
    material: i@gold_nugget
    display name: <&6>+1
    lore:
    - <&e>Deposit 1 Wun

DEPOSIT_TEN_WUN:
    type: item
    material: i@gold_ingot
    display name: <&6>+10
    lore:
    - <&e>Deposit 10 Wun

DEPOSIT_HUNDRED_WUN:
    type: item
    material: i@gold_block
    display name: <&6>+100
    lore:
    - <&e>Deposit 100 Wun

ONE_WUN:
    type: item
    material: i@gold_nugget
    display name: <&6>One Wun
    lore:
    - <&7>A small coin engraved with
    - <&7>the face of the first avatar.

TEN_WUN:
    type: item
    material: i@gold_ingot
    display name: <&6>Ten Wun
    lore:
    - <&7>A long ingot engraved with
    - <&7>a pattern resembling raava.

HUNDRED_WUN:
    type: item
    material: i@gold_block
    display name: <&6>A Hundred Wun
    lore:
    - <&7>Wow. You could buy a lot
    - <&7>with this!

#######################################################
##                     Ledger Tasks                  ##
#######################################################