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


Click here to create your own public paste ~ ~ click to duplicate and edit this paste


TitleEdit of P#12144 - Untitled Paste
TypeDenizen Script
Date2014/12/16 21:57:58 UTC-08:00
ByAnthony
Other
Paste
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
12100
dRegions_Claim:
  type: task
  claim:
  # /drg claim [ID]
    - inject locally prerun instantly
    # Check Global region limits
    - define globalRegionLimit '<yaml[dregions_global_config].read[config.regions.claim.max-region-count-per-player]||0>'
    - if <def[globalRegionLimit].is[MORE].than[0]> {
      - define playerGlobalRegions 'li@'
      - foreach <server.list_worlds.parse[name]> {
        - define thisWorld '%value%'
        - foreach '<yaml[dRegions_%thisWorld%_regions].list_keys[regions].exclude[__global__].alphanumeric||li@>' {
          - define region '%value%'
          - if <proc[dRegions_IsOwner].context[<def[region]>|<def[thisWorld]>|<def[player].as_player>]||false> {
            - define playerGlobalRegions '<def[playerGlobalRegions].include[<def[region]>]||<def[playerGlobalRegions]>>'
            }
          }
        }
      - if <def[playerGlobalRegions].size.is[OR_MORE].than[%globalRegionLimit%]> {
        - run s@dRegions_Msg 'def:<&c>You already have <def[playerGlobalRegions].size> total regions!'
        - queue clear
        }
      }
    # Check World region limits
    - define worldRegionLimit '<yaml[dregions_%world%_config].read[config.regions.claim.max-region-count-per-player]||0>'
    - if <def[worldRegionLimit].is[MORE].than[0]> {
      - define playerWorldRegions 'li@'
      - foreach '<yaml[dRegions_%world%_regions].list_keys[regions].exclude[__global__].alphanumeric||li@>' {
        - define region '%value%'
        - if <proc[dRegions_IsOwner].context[<def[region]>|<def[world]>|<def[player].as_player>]||false> {
          - define playerWorldRegions '<def[playerWorldRegions].include[<def[region]>]||<def[playerWorldRegions]>>'
          }
        }
      - if <def[playerWorldRegions].size.is[OR_MORE].than[%worldRegionLimit%]> {
        - run s@dRegions_Msg 'def:<&c>You already have <def[playerWorldRegions].size> regions in this world!'
        - queue clear
        }
      }
    # Check selection volume
    - define globalClaimVol '<yaml[dregions_global_config].read[config.regions.claim.max-volume]||0>'
    - inject s@dWE_Commands p:selection_Size instantly
    - if <def[globalClaimVol].is[MORE].than[0]> {
      - if <def[size].is[MORE].than[%globalClaimVol%]> {
        - run s@dRegions_Msg 'def:<&c>Your selection exceeds the global limit!'
        - run s@dRegions_Msg 'def:<&7><&o>Selected <&8>(<&7><&o>%size%<&8><&7><&o>Limit <&8>(<&7><&o>%globalClaimVol%<&8><&7><&o>Over <&8>(<&7><&o><def[size].sub[%globalClaimVol%].as_int><&8>)'
        - queue clear
        }
      }
    - define worldClaimVol '<yaml[dregions_%world%_config].read[config.regions.claim.max-volume]||0>'
    - if <def[worldClaimVol].is[MORE].than[0]> {
      - if <def[size].is[MORE].than[%worldClaimVol%]> {
        - run s@dRegions_Msg 'def:<&c>Your selection exceeds the world limit!'
        - run s@dRegions_Msg 'def:<&7><&o>Selected <&8>(<&7><&o>%size%<&8><&7><&o>Limit <&8>(<&7><&o>%worldClaimVol%<&8><&7><&o>Over <&8>(<&7><&o><def[size].sub[%worldClaimVol%].as_int><&8>)'
        - queue clear
        }
      }
    # Check inside existing/owned region
    - if '<yaml[dregions_global_config].read[config.regions.claim.only-inside-existing-regions]||false>' {
      - if <def[playerWorldRegions].exists.not> {
        - define playerWorldRegions 'li@'
        - foreach '<yaml[dRegions_%world%_regions].list_keys[regions].exclude[__global__].alphanumeric||li@>' {
          - define region '%value%'
          - if <proc[dRegions_IsOwner].context[<def[region]>|<def[world]>|<def[player].as_player>]||false> {
            - define playerWorldRegions '<def[playerWorldRegions].include[<def[region]>]||<def[playerWorldRegions]>>'
            }
          }
        }
      - define cuboids '<def[playerWorldRegions].parse[replace[regex:^()].with[cu@dregions_%world%_]].filter[is[matches].to[cuboid]]||li@>'
      - foreach %cuboids% {
        - if <def[pos1].is_within[%value%]>
          && <def[pos2].is_within[%value%]> {
          - define isWithin ''
          }
        }
      - if <def[isWithin].exists.not> {
        - run s@dRegions_Msg 'def:<&c>You may only claim regions within land you own'
        - queue clear
        }
      }
    # 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]> {
      - run s@dRegions_Msg 'def:<&c>Region already exists!'
      - run s@dRegions_Msg 'def:<&7>You must want to update the region'
      # Check if is owner
      # Remove commented lines and re-indent to allow admins to "redefine" existing claims.
      # Otherwise, just use the redefine command as intended!
#      - 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
        }
#        }
      - define update ''
      }
    # Check for overlapping regions
    - if !<player.has_permission[dregions.admin]||false> {
      - if <proc[dRegions_RegionOverlaps].context[<def[selectedCuboid].replace[cu@].replace[|].with[/]>|%name%|%world%|<player>]> {
        - run s@dRegions_Msg 'def:<&c>Region selection contains unowned regions!'
        - queue clear
        }
      }
    # Update the region
    - if <def[update].exists||false> {
      - 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 'savefile:dRegions/worlds/%world%/regions.yml' 'id:dRegions_%world%_regions'
      - note cu@<def[selectedCuboid].min.simple>|<def[selectedCuboid].max.simple> 'as:dregions_%world%_%name%'
      - run s@dRegions_Msg 'def:<&f><&o>%name%<&7><&o> updated to selection'
      }
      else {
      - define ownerPlayers 'li@<player.uuid>'
      - inject s@dRegions p:createRegionEntry instantly
      - run s@dRegions_Msg 'def:<&7><&o>Created %name% in %world%'
      }



RawRaw



Pastes made: 66590