Paste #44572: Untitled Paste

Date: 2017/09/22 11:40:31 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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832


#######################################################
##                 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[dNations/<def[value]>.yml]> {
                    - yaml create id:<def[value]>
                    - yaml "savefile:dNations/<def[value]>.yml" id:<def[value]>
                    }
                - choose "<def[value]>":
                    - case "ek":
                        - yaml id:ek set ranks.politics:<li@messenger|diplomat|ambassador|advisor>
                        - yaml id:ek set ranks.military:<li@recruit|trooper|seargeant|general>
                        - yaml id:ek set ranks.government:<li@mayor|minister|regent|leader>
                        - yaml "savefile:dNations/ek.yml" id:<ek>
                    - case "fn":
                        - yaml id:fn set ranks.citizen:<li@initiate|apprentice|journeyman|craftsman|master|elder>
                        - yaml id:fn set ranks.military:<li@trainee|private|seargeant|lieutenant|colonel|general>
                        - yaml id:fn set ranks.government:<li@initiate_sage|sage|grandsage|lord|heir|leader>
                        - yaml id:fn set ranks.service:<li@engineer|head_engineer|royal_guard|grand_guard|marshal|field_marshal>
                        - yaml id:fn set ranks.navy:<li@privateer|officer|captain|admiral|tactician|grand_tactician>
                        - yaml "savefile:dNations/fn.yml" id:<fn>
                    - case "wt":
                        - yaml id:wt set ranks.healer:<li@herbalist|apprentice|healer|seniorhealer|dukun>
                        - yaml id:wt set ranks.military:<li@recruit|warrior|captain|commodore|admiral>
                        - yaml id:wt set ranks.government:<li@diplomat|chieftain|elder|heir|leader>
                        - yaml id:wt set ranks.shamans:<li@acolyte|shaman|great_shaman>
                        - yaml "savefile:dNations/wt.yml" id:<wt>
                    - case "nat":
                        - yaml id:nat set ranks:<li@monk|senior_monk|iron_wind|leader|guru>
                        - yaml "savefile:dNations/nat.yml" id:<nat>
                    - case "eat":
                        - yaml id:eat set ranks:<li@monk|senior_monk|iron_wind|leader|guru>
                        - yaml "savefile:dNations/eat.yml" id:<eat>
                    - case "sat":
                        - yaml id:sat set ranks:<li@monk|senior_monk|iron_wind|leader|guru>
                        - yaml "savefile:dNations/sat.yml" id:<sat>
                    - case "wat":
                        - yaml id:wat set ranks:<li@monk|senior_monk|iron_wind|leader|guru>
                        - yaml "savefile:dNations/wat.yml" id:<wat>
                    - case "bht":
                        - yaml id:bht set ranks.shaman:<li@acolyte|shaman|highshaman|headshaman|greatshaman>
                        - yaml id:bht set ranks.villager:<li@farmer|builder|guardian|advisor|villagechief>
                        - yaml id:bht set ranks.sage:<li@apprentice|sage|highsage|grandsage|chief>
                    - default:
                        - narrate "<&c><def[value]> does not exist or does not have any ranks setup!"
        - case "save":
            - foreach <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst> {
                    - yaml "savefile:dNations/<def[value]>.yml" id:<def[value]>
                    - narrate "<&a>All nation files saved."
                    }
        - case "remove":
            - yaml id:<player.flag[nation]> set members:->:<context.args.get[2]>:!
            - yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>
            - narrate "<&c><context.args.get[2]> has been removed from the nation!"
                }
        - 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]>].list_keys[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]>].list_keys[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":
            - choose "<context.args.size>":
                - case "2":
                    - choose "<context.args.get[2]>":
                        - case "apply":
                            - narrate "<&5><&l>- /nation apply:"
                            - narrate "<&d>Use this command to join a nation! An application will be created for you and filled out automatically. When the relevant nation leader views it, they will either accept or deny the application. In either case, you will receive an email."
                            - narrate "<&d><&l>Make sure to use the nation ID or the command will not work!"
                            - narrate "<&d>Valid nation IDs: wt, fn, ek, nat, sat, eat, wat, bht, sw, fst, bhs."
                            - narrate "<&d>Note: Some nations may not have a leader, in which case you will not receive a response."
                        - case "leave":
                            - narrate "<&5><&l>- /nation leave:"
                            - narrate "<&d>Use this command to leave a nation. Warning: if you wish to rejoin at a later date, you will have to make another application."
                        - case "apps":
                            - narrate "<&5><&l>- /nation apps:"
                            - narrate "<&5>- Nation Leader Command -"
                            - narrate "<&d>This command will list all pending apps, if you have any. Use /nation apps <&gt>player<&lt> to view that player's app, and /nation apps <&gt>player<&lt> <&gt>accept/deny<&lt> to act upon it."
                            - narrate "<&d>You will not receive a notification when a player makes a new app, so you should check back to this list frequently."
                        - case "banish":
                            - narrate "<&5><&l>- /nation banish <&gt>player<&lt>:"
                            - narrate "<&5>- Nation Leader Command -"
                            - narrate "<&d>Use this to banish particularly unruly players from your nation. This will prevent them from making a new application forever, unless you pardon them."
                            - narrate "<&c>Note: /nation pardon has not been implemented yet!"
                        - case "claim":
                            - narrate "<&5><&l>- /nation claim <&gt>player<&lt>:"
                            - narrate "<&5>- Nation Leader Command -"
                            - narrate "<&d>This will claim the chunk you're standing in, if the chunk is unclaimed and adjacent to a chunk already belonging to you, or a core chunk. If a nation has already claimed that chunk, your power levels will be compared, and the greater power will prevail. You cannot overclaim a nation core. After wars, power points will be given by staff for territory grants. Make sure to claim your territory!"
                        - case "core":
                            - narrate "<&5><&l>- /nation claim <&gt>player<&lt>:"
                            - narrate "<&5>- Nation Leader Command -"
                            - narrate "<&d>Use this command to set a nation core. Cores are central, claimed chunks from which you expand your claim. A nation should have a central core for their capital and each major city."
                        - case "war":
                            - narrate "<&5><&l>- /nation claim <&gt>player<&lt>:"
                            - narrate "<&5>- Nation Leader Command -"
                            - narrate "<&d>Use this command to declare war on another nation."
                            - narrate "<&c>Warning: /nation peace has not yet been implemented."
                        - default:
                            - narrate "<&c>There is no such command in dNations!"
                - default:
                    - 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 core <&gt>ID<&lt>: Creates a 'core' chunk with the name <&gt>ID<&lt>."
                        - 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 "core":
            - if <player.flag[rank]> == leader {
                - if <context.args.size> == 2 {
                        - narrate "<&a>Setting nation core as '<context.args.get[2]>'"
                        - yaml id:<player.flag[nation]> set claimed_chunks.<player.location.chunk>:core
                        - yaml id:<player.flag[nation]> set cores:!
                        - yaml id:<player.flag[nation]> set cores.<player.location.chunk>:<context.args.get[2]>
                        - yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>
                }
                else {
                    - narrate "<&c>You must specify an ID!"
                }
            }
            else {
                - narrate "<&c>You must be a nation leader to set a core chunk!"
            }
        - case "claim":
            - if <player.flag[rank]> == leader {
                - define unclaimed true
                 - if <yaml[<player.flag[nation]>].read[claimed_chunks].contains[<player.location.chunk>]||false> {
                    - narrate "<&c>You can't claim a chunk that you already own!"
                    - define unclaimed false
                }
                - if !<yaml[<player.flag[nation]>].read[claimed_chunks].contains_any[li@<player.location.chunk.add[0,1]>|<player.location.chunk.add[0,-1]>|<player.location.chunk.add[1,0]>|<player.location.chunk.add[-1,0]>]||false> {
                    - narrate "<&c>Your claimed chunk must be adjacent to your currently claimed territory!"
                    - define unclaimed false
                }
                - foreach <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|fst> {
                    - if <yaml[<def[value]>].read[claimed_chunks].contains[<player.location.chunk>]||false> && <yaml[<def[value]>].read[power]||0> > <yaml[<player.flag[nation]>].read[power]||0> && !<yaml[<player.flag[nation]>].read[enemies].contains[<def[value]>]||false> {
                        - 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>:basic
                    - yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>
                }
            }
            else {
                - narrate "<&c>Only nation leaders can claim land!"
            }
        - case "unclaim":
            - if <player.flag[rank]> == leader {
                - if <yaml[<player.flag[nation]>].read[claimed_chunks].contains[<player.location.chunk>]> {
                    - yaml id:<player.flag[nation]> set claimed_chunks.<player.location.chunk>:!
                    - yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>
                    - narrate "<&a>You have unclaimed this chunk!"
                }
                else {
                    - narrate "<&c>You can't unclaim a chunk you don't own!"
                }
            }
        - 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 set pending_apps.<context.args.get[2]>:! id:<player.flag[nation]>
                    - yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>
                    - flag <context.args.get[2]> nation:<player.flag[nation]>
                    - yaml set members:->:<context.args.get[2]> id:<player.flag[nation]>
                    - yaml "savefile:dNations/<player.flag[nation]>.yml" id:<player.flag[nation]>
                    - 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]>"
            }

#######################################################
##                  Ranks Handling                   ##
#######################################################

RANK_PROC:
    type: procedure
    script:
    - choose <player.flag[nation]>:
        - case "eat":
            - define value "&7Eastern_<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "sat":
            - define value "&7Southern_<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "nat":
            - define value "&7Northern_<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "wat":
            - define value "&7Western_<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "wt":
            - define value "&3<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "fn":
            - define value "&4<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "ek":
            - define value "&2<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "bht":
            - define value "&c<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "fst":
            - define value "&a<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "sw":
            - define value "&6<player.flag[rank].to_titlecase>_"
            - determine %value%
        - case "bhs":
            - define value "&e<player.flag[rank].to_titlecase>_"
            - determine %value%

RANKS_CHANGE:
    type: task
    script:
    #- foreach <yaml[<player.flag[nation]>].list_keys[permissions.<player.flag[rank]>]> {
        #- execute as_server "pex user <player.name> add <def[value]>"
    #}
    - execute as_server "pex user <player.name> prefix set <&dq><proc[rank_proc]><&dq>"

#######################################################
##                  Pay Commands                     ##
#######################################################

PAY_COMMAND:
    type: command
    name: pay
    aliases:
    - p
    script:
    - if <server.list_players.formatted.contains[<context.args.get[1]>]> {
        - if <context.args.get[2]> == <number> {
            - flag <context.args.get[1]>
            - flag <player> money:<player.flag[money].sub[<context.args.get[2]>]>
            - narrate "<&a><context.args.get[2]> Wun have been sent to <context.args.get[1]>."
        }
        else {
            - narrate "<&c><context.args.get[2]> is not a valid amount of money!"
        }
    }
    else {
        - narrate "<&c><context.args.get[1]> is not a valid player!"
    }

#######################################################
##                 Nation Passage Message            ##
#######################################################
Nation_Passage:
    type: world
    debug: false
    events:
        on player steps on block:
        - if <context.new_location.chunk> == <context.previous_location.chunk> { - queue clear }
        - foreach <li@ek|fn|wt|nat|eat|sat|wat|bht|bhs|sw|> {
            - if <yaml[<def[value]>].read[claimed_chunks].contains[<context.new_location.chunk>]> {
                - if !<player.has_flag[entered]> {
                    - flag <player> entered
                    - narrate "<&7>You are now entering the <def[value]>."
                    - if <yaml[<player.flag[nation]>].read[enemies].contains[<def[value]>]> {
                        - narrate "<&c>This is an enemy nation. Beware!"
                    }
                }
            }
            - if <yaml[<def[value]>].read[claimed_chunks].contains[<context.previous_location.chunk>]> && <yaml[<def[value]>].read[claimed_chunks].contains[<context.new_location.chunk>].not> {
                - if <player.has_flag[entered]> {
                - narrate "<&7>You are now leaving the <def[value]>."
                - flag <player> entered:!
                }
            }
        }
#######################################################
##                  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:
            - if <player.flag[money]> >= 100 {
                - flag <player> money:-:100
                - give i@HUNDRED_WUN qty:1
            } else {
                - narrate "<&c>You don't have 100 Wun in your account to withdraw!"
            }
            on player clicks WITHDRAW_TEN_WUN in VAULT:
            - if <player.flag[money]> >= 10 {
                - flag <player> money:-:10
                - give i@TEN_WUN qty:1
            } else {
                - narrate "<&c>You don't have 10 Wun in your account to withdraw!"
            }
            on player clicks WITHDRAW_ONE_WUN in VAULT:
            - if <player.flag[money]> >= 1 {
                - flag <player> money:-:1
                - give i@ONE_WUN qty:1
            } else {
                - narrate "<&c>You don't have 1 Wun in your account to withdraw!"
            }
            on player clicks DEPOSIT_HUNDRED_WUN in VAULT:
            - if !<player.inventory.contains[i@HUNDRED_WUN].qty[1]> {
                - narrate "<&c>You don't have any Hundred Wun items to deposit!"
            } else {
                - take i@HUNDRED_WUN
                - flag player money:+:100
            }
            on player clicks DEPOSIT_TEN_WUN in VAULT:
            - if !<player.inventory.contains[i@TEN_WUN].qty[1]> {
                - narrate "<&c>You don't have any Ten Wun items to deposit!"
            } else {
                - take i@TEN_WUN
                - flag player money:+:10
            }
            on player clicks DEPOSIT_ONE_WUN in VAULT:
            - if !<player.inventory.contains[i@ONE_WUN].qty[1]> {
                - narrate "<&c>You don't have any One Wun items to deposit!"
            } else {
                - take i@ONE_WUN
                - flag player money:++
            }

ICTRADE:
    type: inventory
    title: International Trade
    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@NOTHING_HERE] [i@EKICTRADE_ITEM] [i@FNICTRADE_ITEM] [i@WTICTRADE_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@NOTHING_HERE] [i@NOTHING_HERE]"

ICTRADE_HANDLER:
    type: world
    events:
        on player clicks in ICTRADE:
        - determine cancelled
        on player drags in ICTRADE:
        - determine cancelled
        on player clicks EKICTRADE_ITEM in ICTRADE:
        - inventory open d:in@EKICTRADE
        on player clicks FNICTRADE_ITEM in ICTRADE:
        - inventory open d:in@FNICTRADE
        on player clicks WTICTRADE_ITEM in ICTRADE:
        - inventory open d:in@WTICTRADE

EKICTRADE:
    type: inventory
    title: Earth Kingdom International Trade
    size: 27
    slots:
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@ICTRADE_CONFIRM] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE]"
    - "[i@NOTHING_HERE] [i@ICTRADE_SUB_HUNDRED] [i@ICTRADE_SUB_TEN] [i@ICTRADE_SUB_ONE] [i@EKICTRADE_AMOUNT] [i@ICTRADE_PLUS_ONE] [i@ICTRADE_PLUS_TEN] [i@ICTRADE_PLUS_HUNDRED] [i@NOTHING_HERE]"
    - "[i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@ICTRADE_CANCEL] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE] [i@NOTHING_HERE]"

EKICTRADE_HANDLER:
    type: world
    events:
        on player clicks in EKICTRADE:
        - determine cancelled
        on player drags in EKICTRADE:
        - determine cancelled
        on player clicks ICTRADE_CONFIRM in EKICTRADE:
        on player clicks ICTRADE_CANCEL in EKICTRADE:
        - flag player ekictrade_possible_amount:0
        - inventory close d:in@EKICTRADE
        on player clicks ICTRADE_PLUS_ONE in EKICTRADE:
        - flag player ekictrade_possible_amount:++
        - inventory open d:in@EKICTRADE
        on player clicks ICTRADE_PLUS_TEN in EKICTRADE:
        - flag player ekictrade_possible_amount:+:10
        - inventory open d:in@EKICTRADE
        on player clicks ICTRADE_PLUS_HUNDRED in EKICTRADE:
        - flag player ekictrade_possible_amount:+:100
        - inventory open d:in@EKICTRADE
        on player clicks ICTRADE_SUB_ONE in EKICTRADE:
        - flag player ekictrade_possible_amount:-:1
        - inventory open d:in@EKICTRADE
        on player clicks ICTRADE_SUB_TEN in EKICTRADE:
        - flag player ekictrade_possible_amount:-:10
        - inventory open d:in@EKICTRADE
        on player clicks ICTRADE_SUB_HUNDRED in EKICTRADE:
        - flag player ekictrade_possible_amount:-:100
        - inventory open d:in@EKICTRADE

CSALARIES:
    type: inventory
    inventory: CHEST
    title: Salaries
    size: 27
    procedural items:
    - define list li@
    - foreach <yaml[<player.flag[nation]>].read[members]>:
      - define item i@human_skull[skull_skin=<def[value].as_player.uuid>]
      - define list <def[list].include[<def[item]>]>
    - determine <def[list]>
    slots:
    - "[] [] [] [] [] [] [] [] []"
    - "[] [] [] [] [] [] [] [] []"
    - "[] [] [] [] [] [] [] [] []"

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

ICTRADE_CONFIRM:
    type: item
    material: i@green_clay
    display name: <&2><&l>Confirm
    lore:
    - <&a>Send!

ICTRADE_CANCEL:
    type: item
    material: i@red_clay
    display name: <&4><&l>Cancel
    lore:
    - <&c>No! What was I thinking?!

ICTRADE_PLUS_ONE:
    type: item
    material: i@gold_nugget
    display name: <&6>+1 Wun

ICTRADE_PLUS_TEN:
    type: item
    material: i@gold_ingot
    display name: <&6>+10 Wun

ICTRADE_PLUS_HUNDRED:
    type: item
    material: i@gold_block
    display name: <&6>+100 Wun

ICTRADE_SUB_ONE:
    type: item
    material: i@gold_nugget
    display name: <&6>-1 Wun

ICTRADE_SUB_TEN:
    type: item
    material: i@gold_ingot
    display name: <&6>-10 Wun

ICTRADE_SUB_HUNDRED:
    type: item
    material: i@gold_block
    display name: <&6>-100 Wun

EKICTRADE_AMOUNT:
    type: item
    material: i@grass
    display name: <&2>Earth Kingdom
    lore:
    - <&a><player.flag[ekictrade_possible_amount]>

EKICTRADE_ITEM:
    type: item
    material: i@grass
    display name: <&2>Earth Kingdom
    lore:
    - <&a>Need to send some cash to the Earth King?

FNICTRADE_ITEM:
    type: item
    material: i@blaze_powder
    display name: <&4>Fire Nation
    lore:
    - <&c>Need to send some cash to the Fire Lord?

WTICTRADE_ITEM:
    type: item
    material: i@packed_ice
    display name: <&3>Water Tribe
    lore:
    - <&b>Need to send some cash to the Water Chief?

CHECKBUDGET_ITEM:
    type: item
    material: i@gold_nugget
    display name: <&6>Check Budget
    lore:
    - <&e><&o>Money com es 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!

EXIT:
    type: item
    material: i@barrier
    display name: <&4><&l>Exit The Inventory

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