Paste #11459: dRegions - Untested Removing Regions

Date: 2014/11/23 20:24:25 UTC-08: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


################################################################################
#
#                                d R e g i o n s
#
#
#   Authors: |Anthony|
#   Version: 0.1
#   dScript Version: 0.9.6-DEV_b146
#
#
#
#--- About this script
#
#  This is a basic recreation of WorldGuard in denizen
#
#
#
################################################################################
#
#  dRegions World Events Script
#
#  This should cover all dRegions related world events.
#
dRegions:
  type: world
  debug: false
  events:
    on player clicks block:
      - if <c.item.scriptname.split[_].get[1].is[!=].to[dRegions]||true> queue clear
      - determine passively CANCELLED
      - inject <c.item.scriptname.as_script> instantly

    on server start:
    - run locally start delay:2t


  start:
    - inject locally loadYaml


  loadYaml:
  # Reloads the yaml files and generates default files if they don't exist.
    - announce "<&b>dRegions<&co><&3> Loading system config files..." to_console
    - if !<server.has_file[dRegions/config.yml]> {
      - define world 'GLOBAL'
      - define file 'config'
      - if <player.is[!=].to[null]||false> {
        - flag <player> ConfigFileGeneratorNotify:true
        - inject locally createConfigFile
        - flag <player> ConfigFileGeneratorNotify:!
        - run s@dRegions_Msg 'def:<&7><&o>Created <&f><&o>%world%<&7><&o> config file!'
        }
        else inject locally createConfigFile
      - announce "<&b>dRegions<&co> <&7><&o>Created <&f><&o>%world%<&7><&o> config file!" to_console
      }
    - if <yaml.list.contains[dRegions_GLOBAL_config]> yaml unload 'id:dRegions_GLOBAL_config'
    - yaml 'load:dRegions/config.yml' 'id:dRegions_GLOBAL_config'

    - foreach <server.list_worlds> {
      - define world '<def[value].name>'

      - define file 'worlds/%world%/config'
      - if !<server.has_file[dRegions/%file%.yml]> {
        - if <player.is[!=].to[null]||false> {
          - flag <player> ConfigFileGeneratorNotify:true
          - inject locally createConfigFile
          - flag <player> ConfigFileGeneratorNotify:!
          - run s@dRegions_Msg 'def:<&7><&o>Created <&f><&o>%world%<&7><&o> config file!'
          }
          else inject locally createConfigFile
        - announce "<&b>dRegions<&co> <&7><&o>Created <&f><&o>%world%<&7><&o> config file!" to_console
        }
      - if <yaml.list.contains[dRegions_%world%_config]> yaml unload 'id:dRegions_%world%_config'
      - yaml 'load:dRegions/%file%.yml' 'id:dRegions_%world%_config'

      - define file 'worlds/%world%/regions'
      - if !<server.has_file[dRegions/%file%.yml]> {
        - define region '__global__'
        - if <player.is[!=].to[null]||false> {
          - flag <player> ConfigFileGeneratorNotify:true
          - inject locally createRegionFile
          - flag <player> ConfigFileGeneratorNotify:!
          - run s@dRegions_Msg 'def:<&7><&o>Created <&f><&o>%world%<&7><&o> regions file!'
          }
          else inject locally createRegionFile
        - announce "<&b>dRegions<&co> <&7><&o>Created <&f><&o>%world%<&7><&o> regions file!" to_console
        }
      - if <yaml.list.contains[dRegions_%world%_regions]> yaml unload 'id:dRegions_%world%_regions'
      - yaml 'load:dRegions/%file%.yml' 'id:dRegions_%world%_regions'
      }
    - announce "<&b>dRegions<&co><&a> System config files Loaded!" to_console

  reloadYaml:
    - announce "<&b>dRegions<&co><&3> Reloading system config files..." to_console
    - run s@dRegions_Msg 'def:<&7><&o>Reloading system config files...'
    - if <yaml.list.contains[dRegions_GLOBAL_config]> yaml unload 'id:dRegions_GLOBAL_config'
    - yaml 'load:dRegions/config.yml' 'id:dRegions_GLOBAL_config'
    - foreach <server.list_worlds> {
      - define world '<def[value].name>'
      - if <yaml.list.contains[dRegions_%world%_config]> yaml unload 'id:dRegions_%world%_config'
      - yaml 'load:dRegions/worlds/%world%/config.yml' 'id:dRegions_%world%_config'
      - if <yaml.list.contains[dRegions_%world%_regions]> yaml unload 'id:dRegions_%world%_regions'
      - yaml 'load:dRegions/worlds/%world%/regions.yml' 'id:dRegions_%world%_regions'
      }
    - announce "<&b>dRegions<&co><&a> System config files Loaded!" to_console
    - run s@dRegions_Msg 'def:<&7><&o>System config files Loaded!'


  createConfigFile:
    - define readID 'dRegions_Configurations'
    - define writeID 'dRegions_%world%_config'
    - if !<yaml.list.contains[%readID%]> yaml 'load:<script.relative_filename>' 'id:%readID%'
    - yaml create 'id:%writeID%'
    - define readPath '%readID%.config'
    - define writePath 'config'
    - run s@ConfigFileGenerator def:%readID%|%writeID%|%readPath%|%writePath%|false|false|false instantly
    - yaml unload 'id:%readID%'
    - yaml 'savefile:dRegions/%file%.yml' 'id:%writeID%'


  createRegionFile:
    - define readID 'dRegions_Configurations'
    - define writeID 'dRegions_%world%_regions'
    - if !<yaml.list.contains[%readID%]> yaml 'load:<script.relative_filename>' 'id:%readID%'
    - yaml create 'id:%writeID%'
    - define readPath '%readID%.regions.__global__'
    - define writePath 'regions.%region%'
    - run s@ConfigFileGenerator def:%readID%|%writeID%|%readPath%|%writePath%|false|false|false instantly
    - yaml unload 'id:%readID%'
    - yaml 'savefile:dRegions/%file%.yml' 'id:%writeID%'


  createRegionEntry:
    - if !<yaml.list.contains[dRegions_%world%_regions]> yaml 'load:dRegions/worlds/%world%/regions.yml' 'id:dRegions_%world%_regions'
    - yaml set 'regions.%name%.type:cuboid' 'id:dRegions_%world%_regions'
    - yaml set 'regions.%name%.min:<def[selectedCuboid].min.simple>' 'id:dRegions_%world%_regions'
    - yaml set 'regions.%name%.max:<def[selectedCuboid].max.simple>' 'id:dRegions_%world%_regions'
    - yaml set 'regions.%name%.priority:0' 'id:dRegions_%world%_regions'
    - yaml set 'regions.%name%.flags:|:' 'id:dRegions_%world%_regions'
    - yaml set 'regions.%name%.owners:|:' 'id:dRegions_%world%_regions'
    - foreach <def[ownerGroups]||li@> {
      - yaml set 'regions.%name%.owners.groups:->:%value%' 'id:dRegions_%world%_regions'
      }
    - foreach <def[ownerPlayers]||li@> {
      - yaml set 'regions.%name%.owners.players:->:%value%' 'id:dRegions_%world%_regions'
      }
    - yaml set 'regions.%name%.members:|:' 'id:dRegions_%world%_regions'
    - yaml 'savefile:dRegions/worlds/%world%/regions.yml' 'id:dRegions_%world%_regions'
    - note cu@<def[selectedCuboid].min.simple>|<def[selectedCuboid].max.simple> 'as:dregions_%world%_%name%'




dRegions_Msg:
  type: item
  debug: false
  material: i@human_skull
  display name: "<&4>[<&6>dRegions<&4>]"
  lore:
  - <&5>Click for Help
  script:
    - ^define text '<&4>[<&6>dRegions<&4>]'
    - ^define hover '<&chr[007B]><i@dRegions_Msg.json><&chr[007D]>'
    - ^define click '/dregions help'
    - ^define button "text:'%text%',clickEvent:<&chr[007B]>action:run_command,value:'%click%'<&chr[007D]>,hoverEvent:<&chr[007B]>action:show_item,value:'%hover%'<&chr[007d]>"
    - ^define spacer "text:'  '"
    - ^define msg "text:'%1%'"
    - ^execute as_server "tellraw <player.name> <&chr[007B]>text:'',extra:[<&chr[007B]>%button%<&chr[007D]>,<&chr[007B]>%spacer%<&chr[007D]>,<&chr[007B]>%msg%<&chr[007D]>]<&chr[007D]>"


################################################################################
#
#  dRegions Command Script Container
#
# This script covers all dRegions commands
#
#
#
#--------------------------------------
#
#  dRegions Command Script Basics
#
# The basic stuff required in a command script container
#
dRegions_Commands:
  type: command
  debug: true
  name: dregions
  description: Denizen Regions Manager
  usage: /dregions
  aliases:
  - drg
  allowed help:
  - determine true
  tab complete:
    - define argList 'li@help|reload|define|redefine|claim|select|info|addowner|removeowner|addmember|removemember|list|flag|setpriority|setparent|teleport|remove'
    - define arg '<c.args.get[1]||null>'
    - if <def[arg].is[==].to[null]>
      || !<def[argList].contains[%arg%]> {
      - inject locally tab_arg_1
      }
      else inject locally tab_%arg%
    - determine '<def[result]||li@>'

  script:
    - define command '<c.args.get[1].escaped||help>'
    - define args 'li@help|reload|define'
    - if !<def[args].contains[%command%]> inject locally help instantly
      else inject locally %command% instantly


#
#  END dRegions Command Script Basics
#--------------------------------------
#
#  dRegions Command TAB Completion
#
# Each of these subscripts handles TAB completion for the positional argument.
#
#
#  tab_arg_1:
#    # This builds a new resultSet list for the possible args
#    - define resultSet li@
#    - foreach %argList% {
#      - if <player.has_permission[dregions.%value%]||false> define resultSet '<def[resultSet].include[%value%]>'
#      }
#    - if <def[resultSet].is_empty||true> {
#      - define result ''
#      }
#      else {
#      - define result '<def[resultSet].filter[starts_with[%arg%]]>'
#      - if <def[result].is_empty> define result %resultset%

  tab_arg_1:
    # This Excludes args from the original argList
    - foreach %argList% {
      - if !<player.has_permission[dregions.%value%]||false> define argList '<def[argList].exclude[%value%]||%argList%>'
      }
    - if <def[argList].is_empty||true> define result 'li@'
      else {
      - define result '<def[argList].filter[starts_with[%arg%]]||li@> '
      - if <def[result].is_empty||true> define result '%argList%'
      }

  tab_help:
    - define result 'li@'

  tab_reload:
    - define result 'li@'

  tab_define:
  # /drg define [ID] (g:group) (player)
    - if <player.has_permission[dregions.define]||false> {
      - define spaces '<c.raw_args.to_list.count[ ]||0>'
      - if <def[spaces].is[==].to[0]> define result 'define [ID]'
        else if <def[spaces].is[==].to[1]> {
        - if <c.args.get[2].is[==].to[null]||true> define result '[ID] (g:group) (player)'
          else define result '<c.args.get[2]> (g:group) (player)'
          }
        else if <def[spaces].is[OR_MORE].than[2]> {
        - define owners '<c.args.remove[1|2]||li@>'
        - if <c.args.find[-w].is[OR_MORE].than[0]||false> {
          - define owners '<def[owners].remove[<def[owners].find[-w]>|<def[owners].find[-w].add[1].as_int>]||li@>'
          }
        - define owner '<def[owners].last||li@>'
        - if <def[owner].starts_with[g:]||false> {
          - define group '<def[owner].replace[g:]>'
          - define groups '<server.list_permission_groups.filter[starts_with[%group%]]||li@>'
          - if <def[groups].is_empty> define groups '<server.list_permission_groups||li@>'
          - define result '<def[groups].parse[replace[regex:^].with[g:]]>'
          }
          else {
          - define result '<server.match_player[%owner%].name||null>'
          - if <def[result].is[==].to[null]||true> define result '<server.list_online_players.parse[name]>'
          }
        }
        else define result 'li@'
      }
      else define result 'li@'

  tab_redefine:
  # /drg redefine [ID]
    - if <player.has_permission[dregions.redefine]||false> {
      - define spaces '<c.raw_args.to_list.count[ ]||0>'
      - define world '<c.args.get[<c.args.find[-w].add[1].as_int>].escaped.as_world.name||<player.player.world||null>>'
      - define regions 'A|List|Of|Regions|You|Own|In|A|World'
      - if <def[spaces].is[==].to[0]> define result 'redefine %regions%'
        else if <def[spaces].is[==].to[1]> define result '%regions%'
        else define result 'li@'
      }
      else define result 'li@'

  tab_claim:
    - define result 'li@'

  tab_select:
    - define result 'li@'

  tab_info:
    - define result 'li@'

  tab_addowner:
    - define result 'li@'

  tab_removeowner:
    - define result 'li@'

  tab_addmember:
    - define result 'li@'

  tab_removemember:
    - define result 'li@'

  tab_list:
    - define result 'li@'

  tab_flag:
    - define result 'li@'

  tab_setpriority:
    - define result 'li@'

  tab_setparent:
    - define result 'li@'

  tab_teleport:
    - define result 'li@'

  tab_remove:
  # /drg remove [ID] -w world
    - if <player.has_permission[dregions.remove]||false> {
      - define spaces '<c.raw_args.to_list.count[ ]||0>'
      - if <def[spaces].is[==].to[0]> define result 'remove [ID] -w world'
        else if <def[spaces].is[==].to[1]> {
        - if <c.args.get[2].is[==].to[null]||true> define result '[ID]'
          else if <c.args.get[2].is[==].to[-w]||false> define result '<server.list_worlds.parse[name].parse[replace[regex:^].with[-w ]]>'
          else if <context.server.not> {
          - define regions '<yaml[dRegions_<player.world.name>_regions].list_keys[regions].exclude[__global__]||li@>'
          - define result '<def[regions].filter[starts_with[<c.args.get[2].escaped>]]||li@>'
          - if <def[result].is_empty||true> define result '%regions%'
          }
          else define result 'li@'
        }
        else if <def[spaces].is[==].to[2]> {
        - if <c.args.get[2].is[==].to[-w]||false> {
          - if <c.args.get[3].is[!=].to[null]||false> define result '<server.list_worlds.parse[name].filter[starts_with[<c.args.get[3].escaped>]]||li@>'
          - if <def[result].is_empty||true> define result '<server.list_worlds.parse[name]||li@>'
          }
          else define result '<server.list_worlds.parse[name].parse[replace[regex:^].with[-w ]]>'
        }
        else if <def[spaces].is[==].to[3]> {
        - if <c.args.get[2].is[==].to[-w]||false> {
          - if <c.args.get[4].is[!=].to[null]||false> {
            - define regions '<yaml[dRegions_<c.args.get[3].escaped>_regions].list_keys[regions].exclude[__global__]||li@>'
            - define result '<def[regions].filter[starts_with[<c.args.get[4].escaped>]]||li@>'
            - if <def[result].is_empty||true> define result '%regions%'
            }
            else define result '<yaml[dRegions_<c.args.get[3].escaped>_regions].list_keys[regions].exclude[__global__]||li@>'
          }
          else {
          - if <c.args.get[4].is[!=].to[null]||false> define result '<server.list_worlds.parse[name].filter[starts_with[<c.args.get[4].escaped>]]||li@>'
            else define result '<server.list_worlds.parse[name]||li@>'
          - if <def[result].is_empty||true> define result '<server.list_worlds.parse[name]||li@>'
          }
        }
        else define result 'li@'
      }
      else define result 'li@'


#
#  END dRegions Command Script Basics
#--------------------------------------
#
#  dRegions Command Arguments
#
# Each of these subscripts is an argument for the root command.
#
  help:
    - if <player.has_permission[dRegions.admin]||<context.context.server||false>> inject locally msgsHelpAdmin instantly
      else inject locally msgsHelpUser instantly
    - inject locally msgsFooter instantly
    - queue clear

  reload:
    - if !<player.has_permission[dRegions.reload]||<player.is_op||<context.player.is_op||<context.context.server||false>>> {
      - inject locally help
      - queue clear
      }
    - inject s@dRegions p:reloadYaml instantly
    - run s@dRegions_Msg 'def:<&7><&o>System files loaded!'


  define:
  # /drg define [ID] (g:group) (player)
    - inject locally prerun instantly
    # Check for existing region
    - define exists '<proc[dRegions_RegionExists].context[%name%|%world%]||true>'
    - if <def[exists].is[==].to[orphan]> {
      - run s@dRegions_Msg 'def:<&c>There is an orphaned region by this name!'
      - run s@dRegions_Msg 'def:<&c>Please notify an admin!'
      - queue clear
      }
      else if <def[exists]> {
      - run s@dRegions_Msg 'def:<&c>There is already a region by this name!'
      - queue clear
      }
    # Check for overlapping regions
    - if !<player.has_permission[dregions.admin]||false> {
      - if <proc[dRegions_RegionOverlaps].context[%name%|%world%|<player>]> {
        - run s@dRegions_Msg 'def:<&c>Region selection contains unowned regions!'
        - queue clear
        }
      }
    # Parse any declaired owners
    - define owners '<c.args.remove[1|2]||li@>'
    - if <c.args.find[-w].is[OR_MORE].than[0]||false> {
      - define owners '<def[owners].remove[<def[owners].find[-w]>|<def[owners].find[-w].add[1].as_int>]||li@>'
      }
    - define ownerGroups li@
    - define ownerPlayers li@
    - foreach %owners% {
      - if <def[value].starts_with[g:]||false> define ownerGroups '<def[ownerGroups].include[<def[value].replace[g:]>]||%ownerGroups%>'
        else {
        - if <util.player_is_valid[%value%].not||true> foreach next
        - define ownerPlayers '<def[ownerPlayers].include[<def[value].uuid>]||%ownerPlayers%>'
        }
      }
    # Create the region
    - inject s@dRegions p:createRegionEntry instantly
    - run s@dRegions_Msg 'def:<&7><&o>Created %name% in %world%'

  redefine:
  # /drg redefine [ID]
    - inject locally prerun instantly
    # Check if region exists
    - define exists '<proc[dRegions_RegionExists].context[%name%|%world%]>'
    - if <def[exists].is[==].to[orphan]> {
      - run s@dRegions_Msg 'def:<&c>There is an orphaned region by this name!'
      - run s@dRegions_Msg 'def:<&c>Please notify an admin!'
      - queue clear
      }
      else if <def[exists].not> {
      - run s@dRegions_Msg 'def:<&c>There is no region by this name!'
      - queue clear
      }
    # Check if is owner
    - if !<player.has_permission[dregions.admin]||false> {
      - if <proc[dRegions_IsOwner].context[%name%|%world%|<player>].not> {
        - run s@dRegions_Msg 'def:<&c>You are not an owner of this region!'
        - queue clear
        }
      }
    # Check for overlapping regions
    - if !<player.has_permission[dregions.admin]||false> {
      - if <proc[dRegions_RegionOverlaps].context[%name%|%world%|<player>]> {
        - run s@dRegions_Msg 'def:<&c>Region selection contains unowned regions!'
        - queue clear
        }
      }
    # Update the region
    - narrate "Stub"

  claim:
    - narrate "Stub"

  select:
    - narrate "Stub"

  info:
    - narrate "Stub"

  addowner:
    - narrate "Stub"

  removeowner:
    - narrate "Stub"

  addmember:
    - narrate "Stub"

  removeemember:
    - narrate "Stub"

  list:
    - narrate "Stub"

  flag:
    - narrate "Stub"

  setpriority:
    - narrate "Stub"

  setparent:
    - narrate "Stub"

  teleport:
    - narrate "Stub"

  remove:
  # /drg remove [ID] -w world
    - inject locally prerun instantly
    # Check if region exists
    - define exists '<proc[dRegions_RegionExists].context[%name%|%world%]>'
    - if <def[exists].is[==].to[orphan]> {
      - run s@dRegions_Msg 'def:<&c>There is an orphaned region by this name!'
      - run s@dRegions_Msg 'def:<&c>Please notify an admin!'
      - queue clear
      }
      else if <def[exists].not> {
      - run s@dRegions_Msg 'def:<&c>There is no region by this name!'
      - queue clear
      }
      else run s@dRegions_Msg 'def:<&3>Preparing to remove %name%'
    # Check if is owner
    - if !<player.has_permission[dregions.admin]||false> {
      - if <proc[dRegions_IsOwner].context[%name%|%world%|<player>].not> {
        - run s@dRegions_Msg 'def:<&c>You are not an owner of this region!'
        - queue clear
        }
        else narrate "You are allowed to remove the region!"
      }
    # Check for child regions and unset parent
    - define regions '<yaml[dRegions_%world%_regions].list_keys[regions].exclude[__global__]||li@>'
    - foreach %regions% {
      - if <yaml[dRegions_%world%_regions].read[regions.%value%.parent].is[==].to[%name%]||false> {
        - yaml set 'regions.%value%.parent:<-:%name%' 'id:dRegions_%world%_regions'
        }
      }
    # Remove the region
    - yaml set 'regions.%name%:!' 'id:dRegions_%world%_regions'
    - note remove 'as:dregions_%world%_%name%'
    - yaml 'savefile:dRegions/worlds/%world%/regions.yml' 'id:dRegions_%world%_regions'
    - run s@dRegions_Msg 'def:<&f><&o>%name%<&7><&o>has been removed from <&f><&o>%world%'

#
#  END dRegions Command Arguments
#--------------------------------------
#
#  dRegions Command Utilities
#
# Just some commonly used code blocks
#
  prerun:
  # Block of checks run before /most/ commands
    - if !<player.has_permission[dRegions.%command%]||<player.player.is_op||false>> {
      - inject locally help
      - queue clear
      }
    - if <c.args.find[-w].is[OR_MORE].than[0]||false> {
      - define world '<c.args.get[<c.args.find[-w].add[1].as_int>].escaped.as_world.name||null>'
      - if <def[world].is[==].to[null]||true> {
        - run s@dRegions_Msg 'def:<&c>Invalid world specfied!'
        - queue clear
        }
      - define args '<c.args.exclude[-w].remove[<c.args.find[-w].add[1].as_int>]>'
      - define name '<def[args].get[2].escaped||null>'
      }
      else define world '<player.world.name>'
    - if <li@define|redefine|claim.contains[%command%]> {
      - define wandType '<player.flag[dWEWand_Type]||cuboid>'
      - if <li@cuboid|extender.contains[%wandType%].not||true> {
        - run s@dRegions_Msg 'def:<&c>You must select a cuboid type region!'
        - queue clear
        }
      - define pos1 '<player.flag[dWEWand].get[1].as_location||null>'
      - define pos2 '<player.flag[dWEWand].get[2].as_location||null>'
      - if <def[pos1].is[==].to[null]>
        || <def[pos2].is[==].to[null]> {
        - run s@dRegions_Msg 'def:<&c>No region selected!'
        - queue clear
        }
      - if <def[pos1].world.name.is[!=].to[%world%]>
        || <def[pos2].world.name.is[!=].to[%world%]> {
        - run s@dRegions_Msg 'def:<&c>Selected region not within specified world!'
        - queue clear
        }
      - define selectedCuboid '<cu@%pos1%|%pos2%>'
      }
    - define name '<def[name]||<c.args.get[2].c.args.get[2].escaped||null>>'
    - if <def[name].is[==].to[null]||true> {
      - run s@dRegions_Msg 'def:<&c>You must specify a name!'
      - queue stop
      }
#    - inject s@dRegions_Commands p:selection_Size instantly
#    - define oldSize '%size%'

#
#  dRegions dRegions Command Utilities
#--------------------------------------
#
#  dRegions Command Messages
#
# These are not complete! They are mostly just stubs till the rest is fleshed out!
#
  msgsHeader:
    - narrate "<&5>|----------------------------------------|"
    - narrate "<&5>|<&sp><&sp><&sp><&6>dRegions   <&7>%msgsHeaderTitle%"
    - narrate "<&5>|<&f>"

  msgsFooter:
    - define anthony "text<&co>'<&7>|Anthony|',clickEvent<&co><&chr[007B]>action<&co>open_url,value<&co>'http<&co>//mineconomy.org'<&chr[007D]>,hoverEvent<&co><&chr[007B]>action<&co>show_item,value<&co>'<&chr[007B]><i@AnthonyBanner.json><&chr[007D]>'<&chr[007D]>"
    - define spacer "text<&co>'  '"
    - define prefix "text<&co>'<&5>|  <&f>Authors<&co>  '"
    - execute as_server "tellraw <player.name> <&chr[007B]>text<&co>'',extra<&co>[<&chr[007B]>%prefix%<&chr[007D]>,<&chr[007B]>%anthony%<&chr[007D]>]<&chr[007D]>"
    - narrate "<&d>|-----------S-c-r-o-l-l---U-p-------------|"

  msgsHelpAdmin:
    - define msgsHeaderTitle 'Admin Help'
    - inject locally msgsHeader instantly
    - narrate "<&5>|<&sp><&sp><&sp><&f>"
    - narrate "<&5>|<&sp><&sp><&f>"
    - narrate "<&5>|<&sp><&sp><&f>"
    - narrate "<&5>|<&sp><&sp><&f>"
    - narrate "<&5>|<&sp><&sp><&f>"
    - narrate "<&5>|<&sp><&sp><&f>"
    - narrate "<&5>|<&sp><&f>"

  msgsHelpUser:
    - define msgsHeaderTitle 'User Help'
    - inject locally msgsHeader instantly
    - narrate "<&5>|<&sp><&sp><&sp><&sp><&f>"
    - narrate "<&5>|<&sp><&sp><&f>"
    - narrate "<&5>|<&sp><&sp><&f>"
    - narrate "<&5>|<&sp><&f>"

#
#  END dRegions Command Messages
#--------------------------------------
#
#  dRegions Other Utilities
#
# Other Utility functions used throughout dRegions
#
##dRegions_HasPerm:
##  I have to think about this more...
##  # A procedure script to check if a player has any of the required permissions for a command
##  # <proc[dRegions_HasPerm].context[command]>
##  type: procedure
##  definition: command
##  constants:
##    define:
##    - admin
##    - define
##    redefine:
##    - admin
##    - redefine
##    - redefine.own.*
##    - redefine.own.%region%
##    - redefine.member.*
##    - redefine.member.%region%
##
##  script:
##    - if '<def[region].exsits.not||true>' determine false
##    - define perms <script.constant[%command%]>


dRegions_IsOwner:
  # A procedure script to check if a player is a region owner
  # <proc[dRegions_IsOwner].context[region|world|player]>
  type: procedure
  definitions: region|world|player
  script:
    - define ownerPlayers '<yaml[dRegions_%world%_regions].read[regions.%region%.owners.players]||li@>'
    - define ownerGroups '<yaml[dRegions_%world%_regions].read[regions.%region%.owners.groups]||li@>'
    - if <def[ownerPlayers].contains[<def[player].uuid>].not||false>
      && <def[ownerGroups].contains_any[<def[player].groups>].not||false> determine false
      else determine true


dRegions_RegionExists:
  # A procedure script to check if a region exists
  # <proc[dRegions_RegionExists].context[region|world]>
  type: procedure
  definitions: region|world
  script:
    - define notables '<cu@dregions_%world%_%region%.is[matches].to[cuboid].not||true>'
    - define regions '<yaml[dRegions_%world%_regions].contains[regions.%region%].not||true>'
    - if %notables% && %regions% determine false
      else if %notables% || %regions% determine orphan
      else determine true


dRegions_RegionOverlaps:
  # A procedure script to check if a region overlaps other (un)owned regions
  # <proc[dRegions_RegionOverlaps].context[region|world|player]>
  # NOTE: We have the ability to return %overlaps% and %unowned% if we want
  type: procedure
  definitions: region|world|player
  script:
    - define regions '<yaml[dRegions_%world%_regions].list_keys[regions].exclude[__global__]||li@>'
    - define notables '<def[regions].parse[replace[regex:^()].with[cu@dregions_%world%_]].filter[is[matches].to[cuboid]]||li@>'
    - define overlaps '<def[notables].filter[intersects[%selectedCuboid%]].parse[replace[cu@dregions_%world%_]]||li@>'
    - define unowned '<def[overlaps].filter[<proc[dRegions_IsOwner].context[%name%|%world%|<player>].not>]||li@>'
    - if <def[unowned].is_empty.not||true> determine true
      else determine false


#
#  END other utilities
#--------------------------------------
#
#  dRegions author banner items
#
# Banner items representing the authors
#
dRegions_Author_Anthony:
  type: item
  material: i@human_skull
  display name: "<&f>             |Anthony|"
  lore:
  - <&7>  Owner<&co> <&e>M<&6>ine<&e>C<&6>onomy <&e>N<&6>etwork
  - <&5>-------------------------
  - <&7>
  - <&7>  I`ve been playing minecraft
  - <&7> and running a server since
  - <&7> 2010. I have fun and share
  - <&7> what I do.
  - <&7>
  - <&9>           Click To Visit
#
#  END dRegions author banner items
#--------------------------------------




################################################################################
#                                                                              #
# Configuration Files                                                          #
#                                                                              #
#   These are the default config files. They will be used to build the default #
# configuration and data storage files.                                        #
#                                                                              #
#______________________________________________________________________________#
#                                                                              #
#______________________________DO_NOT_EDIT_THIS_DATA___________________________#
#______________________________________________________________________________#


dRegions_Configurations:
  type: yaml data

  config:
    version: 0.1
    regions:
      enable: true
      invincibility-removes-mobs: false
      wand: dWE_Wand
      claim:
        max-volume: 0
        only-inside-existing-regions: true
        max-region-count-per-player:
          default: 7
    auto-invincible: false
    protection:
      item-durability: true
      remove-infinite-stacks: false
      disable-xp-orb-drops: false
      disable-obsidian-generators: true
    physics:
      no-physics-gravel: false
      no-physics-sand: false
      allow-portal-anywhere: false
      disable-water-damage-blocks: []
    ignition:
      block-tnt: false
      block-tnt-block-damage: false
      block-lighter: false
    fire:
      disable-lava-fire-spread: false
      disable-all-fire-spread: false
      disable-fire-spread-blocks: []
      lava-spread-blocks: []
    mobs:
      block-creeper-explosions: false
      block-creeper-block-damage: false
      block-wither-explosions: false
      block-wither-block-damage: false
      block-wither-skull-explosions: false
      block-wither-skull-block-damage: false
      block-enderdragon-block-damage: false
      block-fireball-explosions: false
      block-fireball-block-damage: false
      disable-enderman-griefing: false
      block-painting-destroy: false
      block-item-frame-destroy: false
      block-creature-spawn: []
    player-damage:
      disable-fall-damage: false
      disable-lava-damage: false
      disable-fire-damage: false
      disable-lightning-damage: false
      disable-drowning-damage: false
      disable-suffocation-damage: false
      disable-contact-damage: false
      teleport-on-suffocation: false
      disable-void-damage: false
      teleport-on-void-falling: false
      disable-explosion-damage: false
      disable-mob-damage: false
      disable-death-messages: false
    crops:
      disable-creature-trampling: false
      disable-player-trampling: false
    weather:
      prevent-lightning-strike-blocks: []
      disable-lightning-strike-fire: false
      disable-thunderstorm: false
      disable-weather: false
      disable-pig-zombification: false
      disable-powered-creepers: false
      always-raining: false
      always-thundering: false
    dynamics:
      disable-mushroom-spread: false
      disable-ice-melting: false
      disable-snow-melting: false
      disable-snow-formation: false
      disable-ice-formation: false
      disable-leaf-decay: false
      disable-grass-growth: false
      disable-mycelium-spread: false

  regions:
    __global__:
        type: global
        priority: 0
        flags: []
        owners: []
        members: []


#