Paste #10313: Untitled Paste

Date: 2014/10/04 17:46:59 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
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119


ServerStartAncientRealms:
    type: world
    debug: false
    events:
      on server start:
      - run s@ServerAnnouncements
      on vote command:
      - run s@ServerAnnouncementsAncientRealms1
      - determine FULFILLED

ServerAnnouncements:
    type: task
    debug: false
    script:
    - ^announce " "
    - ^announce "<gray><&m>*<&lc>--------------------(*<&r> <dark_red><&o>Info <&r><gray><&m>*)---------------------<&rc>*"
    - ^announce "<&l><white>Vote to contribute to the server!"
    - ^announce "<dark_green>PlanetMinecraft<&co> http://bit.ly/1lA35l6"
    - ^announce "<gray><&m>*<&lc>-------------------------------------------------<&rc>*"
    - ^announce " "
    - wait 500
    - ^announce " "
    - ^announce "<gray><&m>*<&lc>--------------------(*<&r> <dark_red><&o>Info <&r><gray><&m>*)---------------------<&rc>*"
    - ^announce "<&l><white>The Ancient Realms is Hosted by OVH Dedicated Servers"
    - ^announce "<&l><white>Official IP<&co> 213.251.186.118<&co>25565"
    - ^announce "<&l><white>16GB Dedicated Ram"
    - ^announce "<&l><white>CoreTM i7-920 2.66GHZ 4c/ 8t"
    - ^announce "<&l><white>100Mbps Uplink / Location in France" 
    - ^announce "<&l><white>Up to 10.000 Player slots available!"
    - ^announce "<gray><&m>*<&lc>-------------------------------------------------<&rc>*"
    - ^announce " "
    - wait 500
    - ^announce ""
    - ^announce "<gray><&m>*<&lc>-------------------(*<&r> <dark_red><&o>Dynmap <&r><gray><&m>*)--------------------<&rc>*"
    - ^announce ""
    - ^announce "<yellow>Dynmap is available for <green><&n>Custom Survival<&r><green> ( <&lb>C.S<&rb> )<yellow> and"
    - ^announce "<green><&n>Dungeon Realms<&r><green> ( <&lb>D.R<&rb> )"
    - ^announce ""
    - ^announce "<yellow>Dynmap Website<&co> <green><bold>http://bit.ly/1rRpy26<&r>"
    - ^announce ""
    - ^announce "<gray><&m>*<&lc>--------------------------------------------------<&rc>*"
    - ^announce ""
    - wait 500
    - ^announce ""
    - ^announce "<gray><&m>*<&lc>---------------(*<&r> <dark_red><&o>Soulbound <&r><gray><&m>*)---------------<&rc>*"
    - ^announce ""
    - ^announce "<yellow>We have the Soulbound plugin installed! Type<&co> <green><bold>/bind"
    - ^announce "<yellow>to soulbind your item for 1000 Dinars"
    - ^announce ""
    - ^announce "<yellow><green>Soulbound Features<&co>"
    - ^announce "<yellow>- You will not lose soulbound items on death!"
    - ^announce "<yellow>- You can not trade or drop soulbound items!"
    - ^announce "<yellow>- You can not place soulbound items in chests!"
    - ^announce ""
    - ^announce "<gray><&m>*<&lc>--------------------------------------------------<&rc>*"
    - ^announce ""
    - wait 500
    - ^announce ""
    - ^announce "<gray><&m>*<&lc>------------(*<&r> <dark_red><&o>Custom Items <&r><gray><&m>*)---------------<&rc>*"
    - ^announce ""
    - ^announce "<yellow>We have custom items!  Type<&co> <green><bold>/bsguide"
    - ^announce "<yellow>to see what you can forge!"
    - ^announce ""
    - ^announce "<yellow>Special Drops and Rewards<&co>"
    - ^announce "<yellow>- Dragons drop 6 to 23 Dragon Teeths!"
    - ^announce "<yellow>- Completing Mines of Moria gives you 1 Ancient Shard!"
    - ^announce "<yellow>- Killing The final dragon gives you 1 Ancient Shard!"
    - ^announce "<yellow>- Killing The final dragon gives you a random Rusty Armor piece!"
    - ^announce ""
    - ^announce "<dark_purple><bold>WARNING<&co>"
    - ^announce "Players wielding special equipment have portal particles above their heads!"
    - ^announce ""
    - ^announce "<gray><&m>*<&lc>--------------------------------------------------<&rc>*"
    - ^announce ""
    - wait 500
    - run s@ServerAnnouncements

ServerAnnouncementsAncientRealms1:
    type: task
    debug: false
    script:
    - ^narrate " "
    - ^narrate "<gray><&m>*<&lc>--------------------(*<&r> <dark_red><&o>Info <&r><gray><&m>*)---------------------<&rc>*"
    - ^narrate "<dark_green>PlanetMinecraft<&co> http://bit.ly/1lA35l6"
    - ^narrate "<gray><&m>*<&lc>-------------------------------------------------<&rc>*"
    - ^narrate " "



BossAnnouncementBar:
    type: task
    debug: false
    script:
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:200|<white><bold> Welcome To The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:190|<white><bold> Welcome To The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:180|<white><bold> Welcome To The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:170|<white><bold> Welcome To The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:160|<white><bold> Welcome To The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:150|<white><bold>Type <blue><bold><&n>/cmd <white><&r><bold>for a full <bold><&n>Info-List<&r><white><bold> of <blue><bold>The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:140|<white><bold>Type <blue><bold><&n>/cmd <white><&r><bold>for a full <bold><&n>Info-List<&r><white><bold> of <blue><bold>The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:130|<white><bold>Type <blue><bold><&n>/cmd <white><&r><bold>for a full <bold><&n>Info-List<&r><white><bold> of <blue><bold>The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:120|<white><bold>Type <blue><bold><&n>/cmd <white><&r><bold>for a full <bold><&n>Info-List<&r><white><bold> of <blue><bold>The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:110|<white><bold>Type <blue><bold><&n>/cmd <white><&r><bold>for a full <bold><&n>Info-List<&r><white><bold> of <blue><bold>The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:90|<white><bold>Type <blue><bold><&n>/cmd <white><&r><bold>for a full <bold><&n>Info-List<&r><white><bold> of <blue><bold>The <dark_purple><bold>A<blue><bold>n<dark_aqua><bold>c<aqua><bold>i<dark_aqua><bold>e<blue><bold>n<dark_purple><bold>t<dark_purple><bold>R<blue><bold>e<dark_aqua><bold>a<aqua><bold>l<blue><bold>m<dark_purple><bold>s"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:80|<white><bold>The Chat contains Important Info so pay attention!"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:70|<white><bold>The Chat contains Important Info so pay attention!"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:60|<white><bold>The Chat contains Important Info so pay attention!"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:50|<white><bold>The Chat contains Important Info so pay attention!"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:40|<white><bold>The Chat contains Important Info so pay attention!"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:30|<white><bold>The Chat contains Important Info so pay attention!"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:20|<white><bold>The Chat contains Important Info so pay attention!"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar:10|<white><bold>The Chat contains Important Info so pay attention!"
      }
    - wait 0.5
    - if <player.is_online> {
      - adjust <player> "show_boss_bar"
      }
    - run s@BossAnouncementBar delay:6000

MainScoreBoard:
    type: task
    debug: false
    script:
      - ^if !<player.is_online> queue clear
      - ^define scoreboardid <player.uuid>
      - ^define scoreboardid2 <player.uuid>2
      - if <player.flag[scoreboard_switch]> {
        - ^define scoreboardid <player.uuid>2
        - ^define scoreboardid2 <player.uuid>
        }
      - if <player.flag[killed_flag]> {
        - if <player.flag[scoreboard]> != killed {
          - ^scoreboard remove id:%scoreboardid%
          - ^scoreboard remove id:%scoreboardid2%
          }
        - flag player scoreboard:killed
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<bold>Ancient Realms" "lines:<&9>Xp<&co>" Score:<player.flag[xp].as_int>
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<bold>Ancient Realms" "lines:<&9>Xp till next Lvl<&co>" Score:<player.flag[XP].sub[<player.flag[nextlevel]>].as_int>
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<bold>Ancient Realms" "lines:<&9>Level<&co>" Score:<player.flag[xplevel].as_int>
        }
        else {
        - if <player.flag[scoreboard]> != main {
          - ^scoreboard remove id:%scoreboardid%
          - ^scoreboard remove id:%scoreboardid2%
          }
        - flag player scoreboard:main
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9>Players<&co>" Score:<server.list_online_players.size>
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9>McMMo-Lvl<&co>" Score:<player.mcmmo.level>
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9>Money<&co>" Score:<player.money.as_int>
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9>F-Land<&co>" Score:<player.faction.size>
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9>F-Power<&co>" Score:<player.faction.power.as_int>
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9>Players Joined<&co>" Score:<server.list_players.size>
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9>Online Hours<&co>" Score:<player.flag[actualtime].div[60].as_int>
        - ^if !<player.flag[15HDragonSpawn]> == true {
          - scoreboard add id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red>Dragon<&9><&rb> Minutes Left<&co>" Score:<el@950.sub[<player.flag[actualtime]>].as_int>
          }
          - ^if <player.flag[Condor]> == true {
            - ^if <el@100.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@100.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          - ^if <player.flag[Cawthorne]> == true {
            - ^if <el@150.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@150.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          - ^if <player.flag[Griaule]> == true {
            - ^if <el@200.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@200.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          - ^if <player.flag[Sadsxot]> == true {
            - ^if <el@250.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@250.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          - ^if <player.flag[Nithhogr]> == true {
            - ^if <el@300.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@300.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          - ^if <player.flag[Ryujin]> == true {
            - ^if <el@350.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else { 
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@350.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          - ^if <player.flag[Sirrush]> == true {
            - ^if <el@400.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@400.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          - ^if <player.flag[Smaug]> == true {
            - ^if <el@450.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@450.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          - ^if <player.flag[Glaurung]> == true {
            - ^if <el@500.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@500.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          - ^if <player.flag[Zenith]> == true {
            - ^if <el@50.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
              } else {
              - scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@50.sub[<player.flag[dragonactualtime]>].as_int>
              }
            }
          }
      - ^scoreboard remove viewers:<player> id:%scoreboardid2%
      - ^scoreboard add viewers:<player> id:%scoreboardid%
      - flag player scoreboard_switch:<player.flag[scoreboard_switch].not>
      - run s@MainScoreBoard delay:5s

ScoreboardPlayerscript:
    type: world
    debug: false
    events:
      on player joins:
      - flag player scoreboard_switch
      - ^scoreboard remove id:<player.uuid>
      - ^scoreboard remove id:<player.uuid>2
      - ^run s@MainScoreBoard delay:1s
      on player kills entity:
      - flag player killed_flag duration:15s

DragonScoreBoardAdd:
    type: task
    debug: false
    script:
    - ^if !<player.flag[15HDragonSpawn]> == true {
      - ^scoreboard add id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red>Dragon<&9><&rb> Minutes Left<&co>" Score:<el@950.sub[<player.flag[actualtime]>].as_int>
      }
    - ^if <player.flag[Condor]> == true {
      - ^if <el@100.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
        } ^else {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@100.sub[<player.flag[dragonactualtime]>].as_int>
        }
      }
    - ^if <player.flag[Cawthorne]> == true {
      - ^if <el@150.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
        } ^else {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@150.sub[<player.flag[dragonactualtime]>].as_int>
        }
      }
    - ^if <player.flag[Griaule]> == true {
      - ^if <el@200.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
        } ^else {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@200.sub[<player.flag[dragonactualtime]>].as_int>
        }
      }
    - ^if <player.flag[Sadsxot]> == true {
      - ^if <el@250.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
        } ^else {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@250.sub[<player.flag[dragonactualtime]>].as_int>
        }
      }
    - ^if <player.flag[Nithhogr]> == true {
      - ^if <el@300.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
        } ^else {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@300.sub[<player.flag[dragonactualtime]>].as_int>
        }
      }
    - ^if <player.flag[Ryujin]> == true {
      - ^if <el@350.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
        } ^else {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@350.sub[<player.flag[dragonactualtime]>].as_int>
        }
      }
    - ^if <player.flag[Sirrush]> == true {
      - ^if <el@400.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
        } ^else {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@400.sub[<player.flag[dragonactualtime]>].as_int>
        }
      }
    - ^if <player.flag[Smaug]> == true {
      - ^if <el@450.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
        } ^else {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@450.sub[<player.flag[dragonactualtime]>].as_int>
        }
      }
    - ^if <player.flag[Glaurung]> == true {
      - ^if <el@500.sub[<player.flag[dragonactualtime]>].as_int> <= 0 {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:0
        } ^else {
        - ^scoreboard add viewers:<player> id:%scoreboardid% "obj:<&l>Ancient Realms" "lines:<&9><&lb><dark_red><player.flag[DragonNameTag]><&9><&rb> Minutes Left<&co>" Score:<el@500.sub[<player.flag[dragonactualtime]>].as_int>
        }
      }         



# ---------------------------------------------------------------------------- #
#                                                                              |
#                                                                              |
#                            M O T D   M a n a g e r                           |
#                                                                              |
#                       A system for serving custom MOTDs                      |
#                                                                              |
#                                                                              |
#   Author: |Anthony|                                                          |
#   Version: 0.1                                                               |
#   dScript Version: 0.9.5-b150X                                               |
#                                                                              |
#   Dependencies:                                                              |
#   - ConfigFileGenerator:    http://scripts.citizensnpcs.co/view/0coo5b       |
#                                                                              |
# ---------------------------------------------------------------------------- #
# 
# 
# ABOUT:
# 
#   MOTD Manager stores the IP address of players that connect to your server.
# It will then use this list of IP:player to check the player for a permission
# and send them a random message from the appropriate category when they view
# their server list in their client.
# 
# 
# USAGE:
# 
#  - Edit the messages.yml file that is generated on first run
#    - Edit the messages for the existing categories
#    - Create new categories if needed
#    - You can use denizen tags inside the messages to display dynamic content
#      to the viewer.
#    - After editing the messages.yml file you must reload the config files
#      /motd reload
# 
#  - Assign players the desired motd.<category> permission node.
# 
#  - Reset the config file
# 
# 
# TODO - Future Feature Fluff:
#    
#    - Add better command support
#      - Ability to list/view/edit/create/delete categories and messages
# 
#    - Maybe make it not write to the IPlist.yml if the info is the same
# 
#______________________________________________________________________________#


'ServerPing':
  type: world
  debug: false

  events:
    # What happens when a player (or bot) pings the server
    on server list ping:
    - inject locally ping instantly

    on player joins:
    - run locally join instantly
    - if <player.in_group[Leader]> {
      - flag MOTDGroup:staff
      }
      else if <player.in_group[Co-Leader]> {
      - flag MOTDGroup:staff
      }
      else if <player.in_group[HighAdmin]> {
      - flag MOTDGroup:staff
      }
      else if <player.in_group[Admin]> {
      - flag MOTDGroup:staff
      }
      else if <player.in_group[Moderator]> {
      - flag MOTDGroup:staff
      }
      else if <player.in_group[Legend]> {
      - flag MOTDGroup:Donators
      }
      else if <player.in_group[Dawnguard]> {
      - flag MOTDGroup:Donators
      }
      else if <player.in_group[ArchDuke]> {
      - flag MOTDGroup:Donators
      }
      else if <player.in_group[King]> {
      - flag MOTDGroup:Members
      }
      else if <player.in_group[Lord]> {
      - flag MOTDGroup:Members
      }
      else if <player.in_group[Baron]> {
      - flag MOTDGroup:Members
      }
      else if <player.in_group[Count]> {
      - flag MOTDGroup:Members
      }
      else if <player.in_group[Crusader]> {
      - flag MOTDGroup:Members
      }
      else if <player.in_group[Vanguard]> {
      - flag MOTDGroup:Members
      }
      else if <player.in_group[Warden]> {
      - flag MOTDGroup:Members
      }
      else if <player.in_group[Knight]> {
      - flag MOTDGroup:Members
      }
      else if <player.in_group[Peasant]> {
      - flag MOTDGroup:Members
      }
      else if <player.flag[Banned]> == true {
      - flag MOTDGroup:Banned
      }

    on server start:
    - run locally loadYaml instantly delay:2s

    on motd command:
    - if !<context.server> {
      - if !<player.has_permission[motd.admin]> queue stop
      }
    - if <c.args.get[1].is[==].to[reload]> {
      - determine passively FULFILLED
      - flag <global> "MainLineMOTD:<white><bold><&m>*<&lc>--<&lb><&r> <dark_purple><bold><&o>A<blue><bold><&o>n<dark_aqua><bold><&o>c<aqua><bold><&o>i<dark_aqua><bold><&o>e<blue><bold><&o>n<dark_purple><bold><&o>t<&r> <dark_purple><bold><&rc><dark_blue><bold><&m>*<blue><bold><&m>-<&r><dark_aqua><bold><&lb><aqua><bold>A <&r><dark_purple>✠<&r> <aqua><bold>R<dark_aqua><bold><&rb><blue><bold><&m>-<dark_blue><bold><&m>*<&r><dark_purple><bold><&lc> <&r><dark_purple><bold><&o>R<blue><bold><&o>e<dark_aqua><bold><&o>a<aqua><bold><&o>l<blue><bold><&o>m<dark_purple><bold><&o>s <&r><white><bold><&m><&rb>--<&rc>*<&r>"
      - run locally loadYaml instantly delay:2s
      - narrate "Configs reloaded!"
      - queue stop
      }
    - if <c.args.get[1].is[==].to[save]> {
      - determine passively FULFILLED
      - run locally save instantly def:ipList
      - run locally save instantly def:messages
      - narrate "Configs saved!"
      - queue stop
      }
    - if <c.args.get[1].is[==].to[--reset]> {
      - determine passively FULFILLED
      - flag <player> ConfigFileGeneratorNotify:true
      - run s@ConfigFileGeneratorHelper def:MOTDManager|messages|false|true|true instantly
      - flag <player> ConfigFileGeneratorNotify:!
      - run locally loadYaml instantly delay:2s
      - queue stop
      }

  ping:
    - define address '<context.address.replace[.].with[-]>'
    - define maxPlayers '<context.max_players>'
    # Do we know this IP?
    - if !<yaml[MOTDManager_ipList].contains[%address%]> {
      - define message '<parse:<yaml[MOTDManager_messages].read[messages.messages.unknown].random>>'
      - determine <def[message]>
      - queue stop
      }
    # Ok, we know this IP
    - define player '<yaml[MOTDManager_ipList].read[%address%].as_player>'
    # Is this person in the minecraft ban file?
    - if <def[player].is_banned> {
      - define message '<parse:<yaml[MOTDManager_messages].read[messages.messages.banned].random>>'
      - determine <def[message]>
      - queue stop
      }
    # Build a list of message types based on the contents of the messages.yml file
    - define messageTypes '<yaml[MOTDManager_messages].list_keys[messages.messages].exclude[unknown|banned]>'
    # Determine which category to pull a message from, then get a random message from that category.
    #  Default to unknown if they don't fit in a category
    - foreach %messageTypes% {
      - if <def[player].flag[MOTDGroup].is[==].to[%value%]> {
        - define message '<parse:<yaml[MOTDManager_messages].read[messages.messages.%value%].random>>'
        - foreach stop
        }
        else {
        - define message '<parse:<yaml[MOTDManager_messages].read[messages.messages.unknown].random>>'
        }
      }
    - determine <def[message]>

  join:
    # Add the player IP as a key with the player object as the value.
    # Using the IP as the key gives us known info on server ping event BUT has
    #  the potential to have stale data since player IP is dynamic (generally).
    # This always writes, even if the node exists. If multiple people connect
    #  from the same IP, it will store the last player to connect.
    - yaml 'write:<player.ip.address.replace[.].with[-].before[<&co>]>' 'value:<player>' id:MOTDManager_ipList
    - run locally save instantly def:ipList

  loadYaml:
    # Loads the yaml files and generates default files if they don't exist.
    - announce "<&b>Loading MOTD Manager config files..." to_console
    - if !<server.has_file[MOTDManager/messages.yml]> {
      - if <player> != null {
        - flag <player> ConfigFileGeneratorNotify:true
        - run s@ConfigFileGeneratorHelper def:MOTDManager|messages|false|true|false instantly
        - flag <player> ConfigFileGeneratorNotify:!
        }
        else run s@ConfigFileGeneratorHelper def:MOTDManager|messages instantly
      }
      else {
      - if <yaml.list.contains[MOTDManager_messages]> yaml unload 'id:MOTDManager_messages'
      }
    - yaml 'load:MOTDManager/messages.yml' 'id:MOTDManager_messages'

    - if !<server.has_file[MOTDManager/ipList.yml]> {
      - yaml create 'id:MOTDManager_ipList'
      - yaml 'write:description' 'value:This file stores a list of IP addresses and the last known player UUID' id:MOTDManager_ipList
      - yaml 'savefile:MOTDManager/ipList.yml' 'id:MOTDManager_ipList'
      }
      else {
      - if <yaml.list.contains[MOTDManager_ipList]> yaml unload 'id:MOTDManager_ipList'
      }
    - yaml 'load:MOTDManager/ipList.yml' 'id:MOTDManager_ipList'
    - announce "<&b>MOTD Manager config files Loaded!" to_console

  save:
    - yaml 'savefile:MOTDManager/%1%.yml' 'id:MOTDManager_%1%'
    - yaml unload 'id:MOTDManager_%1%'
    - yaml 'load:MOTDManager/%1%.yml' 'id:MOTDManager_%1%'




################################################################################
#                                                                              #
# Messages                                                                     #
#                                                                              #
# These are the default messages. They will be used to build the messages.yml  #
#  file. You can add additional messages and categories to that file after it  #
#  has been generated.                                                         #
#                                                                              #
#______________________________________________________________________________#
#                                                                              #
#______________________________DO_NOT_EDIT_THIS_DATA___________________________#
#______________________________________________________________________________#



'MOTDManager_messages':
  type: task
  debug: false

  # Where you save this script file
  scriptPath: 'scripts/MOTDManager.yml'

# Just add new messages and permissions to check.
# The banned and unknown sections are checked outside the other types.

  messages:
    information:
      description:
        - 'Custom MOTD system'
        - 'Display a custom MOTD to players based on a permission.'
        - 'MOTD for Staff groups, player groups, or individual players.'
        - 'This file holds all the messages for the server ping event.'
      usage:
        - 'Add/change the messages in the categories below as needed.'
        - 'We can use denizen tags to add almost any information to the custom'
        - 'messages such as last login time, how much econ money they have, etc.'
        - 'Make sure players have the appropriate permission (listed below).'
        - 'You can create new categories by simply creating a new node under the'
        - 'messages node and assigning players the corresponding permission.'
      permissions:
        - 'motd.trial'
        - 'motd.member'
        - 'motd.expired'
        - 'motd.customNode'
    messages:
      unknown:
        - '<&6>We<&sq>ve never met!<&nl><&e>Here<&sq>s a Second Line!'
      banned:
        - '<&c>You have been Banned <&6><def[player].name>!<&nl><&b>Appeal your ban on the forum!'
      expired:
        - '<&6>Your membership has expired <def[player].name>!<&nl><&e>Go to the forum to renew today!'
      trial:
        - '<&6>We hope you<&sq>re enjoying yourself <&a><def[player].name>!<&nl><&e>You first joined <player.first_played.formatted> ago.'
      member:
        - '<&6>Welcome back <&a><def[player].name>!<&nl><&e>We<&sq>re glad to see you!'
      customNode:
        - '<&6>Hey, you<&sq>re special <&a><def[player].name>!<&nl><&e>C<&sq>mon in, the coffee is fresh!'



#---------------------------------------------------------------------------------------CONFIG FILE GENERATOR------------------------------------------------------------------        

# ---------------------------------------------------------------------------- #
#                                                                              |
#                                                                              |
#                     C o n f i g F i l e G e n e r a t o r                    |
#                                                                              |
#         A system for extracting default config files for your scripts        |
#                                                                              |
#                                                                              |
#   Author: |Anthony|                                                          |
#   Version: 0.3                                                               |
#   dScript Version: 0.9.5-b1518                                               |
#                                                                              |
# ---------------------------------------------------------------------------- #
#                                                                              |
#                                                                              |
# ABOUT:                                                                       |
#                                                                              |
#       Use the ConfigFileGenerator for any scripts that use config files or   |
#     YAML file storage. It will generate any default files for you based on   |
#     what you define in the Configurations Script Container.                  |
#                                                                              |
#       At its core, the ConfigFileGenerator is really a data extraction and   |
#     insertion tool. The provided helper script makes it super easy for end   |
#     users to get basic functionality (creating default config files). More   |
#     advanced users can bypass the helper script and get right to the core.   |
#     The advanced usage allows you to extract data from any yaml file and     |
#     insert it into any other yaml file.                                      |
#                                                                              |
#                                                                              |
# -------------                                                                |
#                                                                              |
# USAGE:                                                                       |
#                                                                              |
#   - Build your Configurations Script Container file as needed following the  |
#     examples shown here.                                                     |
#                                                                              |
#   - Use the ConfigFileGeneratorHelper to generate the files defined in your  |
#     Configurations Script Container.                                         |
#     - run s@ConfigFileGeneratorHelper def:%readID%|%readPath%                |
#                                                                              |
#   - Use the ConfigFileGenerator directly to extract data from any yaml file  |
#     to any other yaml file.                                                  
#     - run s@ConfigFileGenerator def:%readID%|%writeID%|%readPath%|%writePath%|%dryrun%|%verbose%|%forcewrite% instantly
#                                                                              
#                                                                              |
#                                                                              |
#--- Example:                                                                  |
#                                                                              |
#     There is an example Configurations Script Container at the end of this   |
#   file that you can use to see how the ConfigFileGeneratorHelper works.      |
#                                                                              |
#   There is also a command script supplied to make it easy to test. Assign    |
#   youself the denizen.cfg permission node to use the command:  /cfg          |
#                                                                              |
#   This will create 3 files inside /plugins/denizen/ConfigFileGeneratorTest   |
#                                                                              |
#   You can also specify any or all of the 3 options for the /cfg command.     |
#     /cfg --dryrun --verbose --force                                          |
#                                                                              |
#__________                                                                    |
#                                                                              |
################################################################################
#                                                                              #
#                                                                              #
#                 S O M E   N O T   S O   E M P T Y   S P A C E                #
#                                                                              #
#                                                                              #
################################################################################
#
# Config File Generator Helper
#
#   This is specifically for creating NEW files! This script tells the
# s@ConfigFileGenerator which files to generate based on the script
# container you reference. The files names and paths are determined based
# on this info!
#
#   Check the usage below for how to reference your script container.
# 
# 
# Bare minimum usage:
#
#  - Running the script
#
#    This helper script expects that you will have a script container that
#   matches a certain naming convention. It will fail if you do not!
#
#      example:
#        - define readID YourScript
#        - define readPath Configurations
#        - run s@ConfigFileGeneratorHelper def:%readID%|%readPath% instantly
#
#    The above will look for a Script_Container named 'YourScript_Configurations'
#   because it reconstructs the %readPath% to be '%readID%_%readPath%'. After it
#   verifies the Script_Container it will load/reload the yaml file and identify
#   it as %readID% which in our example would be 'YourScript'. It will unload
#   this yaml file when it's finished.
#
#    It then builds a %keylist% from all the child nodes it finds in that
#   Script_Container excluding the required nodes for any script container. The
#   first level child nodes it finds under the Script_Container will each be a
#   new file. Check this example:
#
#      YourScript_Configurations:
#        type: task
#        debug: false
#        script: []
#
#        file1:
#          key: value
#
#        file2:
#          key: value
#
#    This example Script_Container would generate and load 2 new yaml files. It
#   follows a similar naming convention as before. Here's an oversimplification
#   of what it's doing behind the scenes for you:
#    - yaml create 'id:YourScript_file1'
#    - yaml create 'id:YourScript_file2'
#    - yaml 'savefile:YourScript/file1.yml' 'id:YourScript_file1'
#    - yaml 'savefile:YourScript/file2.yml' 'id:YourScript_file1'
#
#    A new folder will be generated in the denizen folder named:   YourScript
#   Inside this folder there will be 2 new files:   file1.yml   file2.yml
#   It will unload these files when it's finished.
#
# -----
#
#  - Injecting the script
#    - define readID
#    - define readPath
#    - inject s@ConfigFileGeneratorHelper
#
#    Alternate functionality is available when injecting this helper script.
#   I'll document that later...
#
#
#
# NOTES:
#
#  - I want to update this so you can specify a single file to build from any
#    config container. Currently it tries to build every file but will not
#    overwrite existing files by default (you CAN specify the --force option)
#
#__________
#
ConfigFileGeneratorHelper:
  type: task
  debug: false
  script:
    - ^define readID '<def[readID]||%1%>'
    - ^define readPath '<def[readPath]||%readID%_%2%>'
    - ^define scriptPath '<s@<def[readPath]>.relative_filename||null>'
    - ^define dryrun '<def[dryrun]||<def[3]||false>>'
    - ^define verbose '<def[verbose]||<def[4]||false>>'
    - ^define forcewrite '<def[forcewrite]||<def[5]||false>>'
    - ^if <def[scriptPath].is[==].to[null]> {
      - announce "<&b>ConfigFileGenerator<&co> <&c><def[readID]> is not a valid readID." to_console
      - queue stop
      }
    - ^if <server.has_file[%scriptPath%]> {
      - if <yaml.list.contains[%readID%]> yaml unload 'id:%readID%'
      - yaml 'load:<def[scriptPath]>' 'id:%readID%'
      }
      else {
      - announce "<&b>ConfigFileGenerator<&co> <&c>%scriptPath% does not exist!" to_console
      - queue stop
      }
    - ^define keylist '<yaml[%readID%].list_keys[%readPath%].exclude[type|debug|scriptPath|script]>'
    - ^if <def[keylist].is_empty> {
      - announce "<&b>ConfigFileGenerator<&co> <&c>The default <def[readID]> config file is emtpy!" to_console
      - yaml unload 'id:%readID%'
      - queue stop
      }
    - ^foreach <def[keylist]> {
      - define file <def[value]>
      - inject s@ConfigFileGeneratorHelper p:buildFile
      }
    - ^announce "<&b>ConfigFileGenerator<&co> <&a><def[readID]> has Completed!" to_console
    - ^announce "<&b>ConfigFileGenerator<&co> <&a><def[readID]> has Completed!" to_flagged:ConfigFileGeneratorNotify
    - ^yaml unload 'id:%readID%'

  buildFile:
    - if !<server.has_file[%readID%/%file%.yml]> || <def[forcewrite]> {
      - announce "<&b>ConfigFileGenerator<&co> <&3>Generating default <def[readID]> %file%.yml file..." to_console
      - announce "<&b>ConfigFileGenerator<&co> <&3>Generating default <def[readID]> %file%.yml file..." to_flagged:ConfigFileGeneratorNotify
      - announce "" to_flagged:ConfigFileGeneratorNotify
      - define newReadPath '%readPath%.%file%'
      - define writePath '%file%'
      - define writeID '%readID%_%file%'
      - yaml create 'id:%writeID%'
      - run s@ConfigFileGenerator def:<def[readID]>|<def[writeID]>|<def[newReadPath]>|<def[writePath]>|<def[dryrun]>|<def[verbose]>|<def[forcewrite]> instantly
      - if !<def[dryrun]> {
        - yaml 'savefile:%readID%/%file%.yml' 'id:%writeID%'
        - announce "<&b>ConfigFileGenerator<&co> <&a><def[readID]> %file%.yml Save Complete!" to_console
        - announce "<&b>ConfigFileGenerator<&co> <&a><def[readID]> %file%.yml Save Complete!" to_flagged:ConfigFileGeneratorNotify
        - announce "" to_flagged:ConfigFileGeneratorNotify
        - yaml unload 'id:%writeID%'
        }
        else {
        - announce "<&b>ConfigFileGenerator<&co> <&a><def[readID]> %file%.yml Dryrun Complete!" to_console
        - announce "<&b>ConfigFileGenerator<&co> <&a><def[readID]> %file%.yml Dryrun Complete!" to_flagged:ConfigFileGeneratorNotify
        - announce "" to_flagged:ConfigFileGeneratorNotify
        - yaml unload 'id:%writeID%'
        }
      }
      else {
      - announce "<&b>ConfigFileGenerator<&co> <&a><def[readID]> %file%.yml already exists!" to_console
      - announce "<&b>ConfigFileGenerator<&co> <&a><def[readID]> %file%.yml already exists!" to_flagged:ConfigFileGeneratorNotify
      }
#
#
################################################################################
#                                                                              #
#                                                                              #
#                 W H A T   A R E   Y O U   L O O K I N G   A T                #
#                                                                              #
#                                                                              #
################################################################################
#
# Config File Generator
#
#
#   This new script differs from the original in that it maintains the readPath
# and writePath seperately! This allows you to extract ALL data from %readPath%
# in your already loaded %readID% yaml file and insert it at any %writePath% in
# the already loaded %writeID% yaml file.
# 
#  example:
#    - define readID 'YourScript'
#    - define writeID 'YourYamlFile'
#    - yaml 'load:Input/FilePath.yml' 'id:%readID%'
#    - yaml 'load:Output/FilePath.yml' 'id:%writeID%'
#    - define readPath 'Some.Yaml.Node.To.Read'
#    - define writePath 'Some.Yaml.Node.To.Write'
#    - run s@ConfigFileGenerator def:%readID%|%writeID%|%readPath%|%writePath%|false|false|false instantly
#    - yaml unload 'id:%readID%'
#    - yaml 'savefile:Output/FilePath.yml' 'id:%writeID%'
#
#__________
# 
ConfigFileGenerator:
  type: task
  debug: false
  definitions: readID|writeID|readPath|writePath|dryrun|verbose|forcewrite
  script:
    - ^define keylist '<yaml[<def[readID]>].list_keys[<def[readPath]>]>'
    - ^if <def[keylist]> != null {
      - inject s@ConfigFileGenerator p:foreachKeylist instantly
      }
      else {
      - define entry '<yaml[<def[readID]>].read[<def[readPath]>]>'
      - if <def[dryrun]> || <def[verbose]> {
        - announce "<&b>ConfigFileGenerator<&co> <&a>Reading<&co> <&b><def[readPath]>" to_console
        - announce "<&b>ConfigFileGenerator<&co> <&a>Reading<&co> <&b><def[readPath]>" to_flagged:ConfigFileGeneratorNotify
        }
      - if <yaml[<def[readID]>].is_list[<def[readPath]>]> {
        - inject s@ConfigFileGenerator p:foreachEntrylist instantly
        }
        else {
        - inject s@ConfigFileGenerator p:singleEntry instantly
        }
      }

  foreachKeylist:
    - foreach <def[keylist]> {
      - define key '<def[value]>'
      - define newReadPath '%readPath%.%key%'
      - define newWritePath '%writePath%.%key%'
      - run s@ConfigFileGenerator def:<def[readID]>|<def[writeID]>|<def[newReadPath]>|<def[newWritePath]>|<def[dryrun]>|<def[verbose]>|<def[forcewrite]> instantly
      }

  foreachEntrylist:
    # This first yaml command clears the node of any values
    - yaml 'write:%writePath%' 'id:%writeID%'
    - foreach <def[entry]> {
      - if !<def[dryrun]> {
        - yaml set <def[writePath]>:->:<def[value]> 'id:<def[writeID]>'
        }
      - if <def[dryrun]> || <def[verbose]> {
        - announce "<&b>ConfigFileGenerator<&co> <&a>Writing<&co> <&9>%writePath%<&co> <&2>%value%" to_console
        - announce "<&b>ConfigFileGenerator<&co> <&a>Writing<&co> <&9>%writePath%<&co> <&2>%value%" to_flagged:ConfigFileGeneratorNotify
        }
      }
    - if <def[dryrun]> || <def[verbose]> {
      - announce "<&b>ConfigFileGenerator<&co> <&3>*-----*" to_flagged:ConfigFileGeneratorNotify
      - announce "" to_flagged:ConfigFileGeneratorNotify
      }

  singleEntry:
    - if <def[dryrun].is[==].to[false]> {
      - yaml 'write:<def[writePath]>' 'value:<def[entry]>' 'id:<def[writeID]>'
      }
    - if <def[dryrun].is[==].to[true]> || <def[verbose].is[==].to[true]> {
      - announce "<&b>ConfigFileGenerator<&co> <&a>Writing<&co> <&c>%writePath%<&co> <&e>%entry%" to_console
      - announce "<&b>ConfigFileGenerator<&co> <&a>Writing<&co> <&c>%writePath%<&co> <&e>%entry%" to_flagged:ConfigFileGeneratorNotify
      - announce "<&b>ConfigFileGenerator<&co> <&4>*-----*" to_flagged:ConfigFileGeneratorNotify
      - announce "<&b>ConfigFileGenerator<&co> " to_flagged:ConfigFileGeneratorNotify
      }
#
#
################################################################################
#                                                                              #
#                    N O T H I N G   T O   S E E   H E R E                     #
#                                                                              #
#                            M O V E   A L O N G                               #
#                                                                              #
################################################################################
#
# Configuration File Generator Command
#
#  Use this to build the example config files. You /could/ use it to build files
# for other scripts, but use at your own risk!
#
# I suppose you could add something like this to accept container names...
#
#    - if <c.args.find[-b].is[MORE].than[0]> {
#      - define file <c.args.get[<c.args.find[-b].add[1].as_int>]>
#      }
#      else {
#      - narrate "<&4>You must specify the readPath!"
#      }
#    - if <c.args.find[-i].is[MORE].than[0]> {
#      - define readID <c.args.get[<c.args.find[-i].add[1].as_int>]>
#      - narrate "%readID%"
#      }
#      else {
#      - narrate "<&4>You must specify the readID!"
#      }
#
#__________
#
'ConfigFileGeneratorCommand':
  type: world
  debug: false
  events:

    on cfg command:
    - if !<player.has_permission[denizen.cfg]> queue stop
    - determine passively fulfilled
    - flag <player> ConfigFileGeneratorNotify:true
    - define dryrun '<tern[<c.args.contains[--dryrun]>]:true || false>'
    - define verbose '<tern[<c.args.contains[--verbose]>]:true || false>'
    - define forcewrite '<tern[<c.args.contains[--force]>]:true || false>'
    - run s@ConfigFileGeneratorHelper def:ConfigFileGeneratorTest|Configurations|%dryrun%|%verbose%|%forcewrite% instantly
    - flag <player> ConfigFileGeneratorNotify:!
#
#
################################################################################
#                                                                              #
#                  A N D   N O W   F O R   S O M E T H I N G                   #
#                                                                              #
#                   C O M P L E T E L Y   D I F F E R E N T                    #
#                                                                              #
################################################################################
#                                                                              #
# Example Configurations Script Container                                      #
#                                                                              #
#                                                                              #
#    The Configurations Script Container is the house for your default files.  #
#   It will be referenced when using the ConfigFileGeneratorHelper.            #
#                                                                              #
#   You are able to store any data needed inside this file. It can handle      #
#   recursive lists too.                                                       #
#                                                                              #
#-- Naming the Container                                                       #
#   * This is important!                                                       #
#                                                                              # 
#   This script container should follow the naming convention:                 #
#       YourScript_Configurations                                              #
#         %readID%_%readPath%                                                  #
#                                                                              #
#   This will be important when you go to run the ConfigFileGeneratorHelper    #
#                                                                              #
#      example:                                                                #
#        - define readID ConfigFileGeneratorTest                               #
#        - define readPath Configurations                                      #
#        - run s@ConfigFileGeneratorHelper def:%readID%|%readPath% instantly   #
#                                                                              #
#                                                                              #
# Each parent node under the script container defines a file name to generate. #
# The child nodes that follow are the entries for that individual file.        #
#                                                                              #
# In this example, 3 files are generated in denizen/ConfigFileGeneratorTest/   #
#                                                                              #
# Although the examples are a bit robotic, they clearly illustrate a range of  #
# usage scenarios.                                                             #
#______________________________________________________________________________#
#                                                                              #
#______________________________DO_NOT_EDIT_THIS_FILE___________________________#
#                                                                              #
#______________________________________________________________________________#

ConfigFileGeneratorTest_Configurations:
  type: task
  debug: false
  script: ''


# ------ Single Value file container ------ #

  singleValues:
    keyA: 1
    keyB: 0.1
    keyC: -1
    keyD: NaN
    keyE: This is a StRiNg!


# ------ Single Lists file container ------ #

  singleLists:
    listA:
      - 1
      - 0.1
      - -1
      - NaN
      - This is a StRiNg!
    listB:
      - 2
      - 0.2
      - -2
      - nAn
      - This is a sTrInG!

# ------ Recursive Lists file container ------ #

  recursiveLists:
    list1:
      list1A:
        list1A1:
          key1A1A: 1
          list1A1A:
            - 1
            - 2
        list1A2:
          list1A2A:
            key1A2A1: 1
            list1A2A1:
              - 1
              - 2
      list1B:
        - 1
        - 2
    list2:
      list2A:
        key2A1: 1
        list2A1:
          - 1
          - 2
      list2B:
        key2B1: 1
        list2B1:
          - 1
          - 2
      list2C:
        key2C1: 1
        list2C1:
          - 1
          - 2


################################################################################