Paste #103410: Unnamed Denizen Script Paste

Date: 2022/11/24 13:13:41 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# -------------------------------------------------- #
# Command: '/claim flags'
# -------------------------------------------------- #

cmd_claims_flags:
    type: task
    debug: false
    definitions: flag|text
    script:

        - if !<proc[claims_ply_inside_claim]>:
            - narrate "<&[red]>You must be standing inside of a claim."
            - stop

        # Getting the ID is only necessary for SQL
        - define global_id <proc[claims_ply_get_global]>
        - define type <proc[claims_ply_get_type]>
        - define claim_id <proc[claims_ply_get_id]>

        # Display the flags menu, otherwise run the command.
        - if !<[flag].exists> || <[flag]> == NULL:
            - run claims_menu_flags_list def:<[global_id]>
            - stop

        # If they have do not have ignore mode on .
        - if !<player.proc[claims_ignoring]>:

            - choose <[type]>:
                - case admin special:
                    - if !<player.proc[player_is_admin]>:
                        - narrate "<&[red]>You do not have permission to edit administrative claims."
                        - stop
                - case section:
                    - define parent_global_id <[global_id].proc[claims_parent]>
                    - if <[parent_global_id].after[-].before[-].is_in[<list[admin|special]>]> <player.proc[player_is_admin]>:
                        - define skip_check true
                    - if <player.proc[claims_ignoring]>:
                        - define skip_check true
                    - if !<[skip_check].if_null[false]> && !<proc[claims_ply_is_manager].context[<player>|<[global_id]>]> && !<proc[claims_ply_is_manager].context[<player>|<[parent_global_id]>]>:
                        - if !<proc[claims_ply_is_member].context[<player>|<[parent_global_id]>]>:
                            - narrate "<&[red]>You do not have access to this sectioned claim."
                            - stop
                        - if !<proc[claims_member_has_permission].context[<player>|<[parent_global_id]>|flags]>:
                            - narrate "<&[red]>You do have permission to change the flags of this sectioned claim."
                            - stop
                - case player:
                    - if !<proc[claims_ply_is_member].context[<player>|<[global_id]>]>:
                        - narrate "<&[red]>You do not have access to this claim."
                        - stop
                    - if !<proc[claims_ply_is_manager].context[<player>|<[global_id]>]> && !<proc[claims_member_has_permission].context[<player>|<[global_id]>|flags]>:
                        - narrate "<&[red]>You do have permission to change the flags of this claim."
                        - stop

        - if !<[flag].exists> || <[flag]> == NULL:
            - narrate "<&[red]>You need to supply a flag name."
            - stop

        # Verify it's a default allowed flag.
        - if !<script[cfg_claims_flags].data_key[flags.<[flag]>].exists>:
            - narrate "<&[red]>The flag <&[yellow]><[flag]><&[red]> is not a valid flag."
            - stop

        - if <script[cfg_claims_flags].data_key[flags.<[flag]>.admin].exists> && !<player.proc[player_is_admin]>:
            - narrate "<&[red]>Only administrators can change the flag <&[yellow]><[flag]><&[red]>."
            - stop

        - choose <script[cfg_claims_flags].data_key[flags.<[flag]>.type]>:
            - case bool:
                - if <[flag]> == allowPvp && <list[NETHER|THE_END].contains[<cuboid[<[global_id]>].world.environment>]>:
                    - narrate "<&[red]>You can not change <&[yellow]><[flag]><&[red]> in this world environment."
                    - stop
                # Defines the status of the current flag we're editing
                - define status <cuboid[<[global_id]>].flag[claim.flags.<[flag]>].if_null[<script[cfg_claims_flags].data_key[flags.<[flag]>.default]>]>
                - if <[status]>:
                    - narrate <script[cfg_claims_flags].parsed_key[flags.<[flag]>.disablemsg]>
                    - flag <cuboid[<[global_id]>]> claim.flags.<[flag]>:false
                - else:
                    - narrate <script[cfg_claims_flags].parsed_key[flags.<[flag]>.enablemsg]>
                    - flag <cuboid[<[global_id]>]> claim.flags.<[flag]>:true
            - case location:
                - if !<player.is_on_ground>:
                    - narrate "<&[red]>You must be on the ground."
                    - stop
                - if !<player.location.proc[location_is_empty]>:
                    - narrate "<&[red]>Your position is not safe, select another area."
                    - stop
                - narrate <script[cfg_claims_flags].parsed_key[flags.<[flag]>.setmsg]>
                - flag <cuboid[<[global_id]>]> claim.flags.<[flag]>:<player.location>
            - case integer:
                - if <[text].if_null[NULL]> == NULL:
                    - narrate <script[cfg_claims_flags].parsed_key[flags.<[flag]>.deleteMsg]>
                    - flag <cuboid[<[global_id]>]> claim.flags.<[flag]>:NULL
                    - stop
                - else:
                    - if !<[text].is_integer>:
                        - narrate "<&[yellow]><[text]> <&[red]>must be an integer."
                        - stop
                    - flag <cuboid[<[global_id]>]> claim.flags.<[flag]>:<[text]>
                    - narrate "<script[cfg_claims_flags].parsed_key[flags.<[flag]>.editmsg]> <&[yellow]><[text].as[duration].formatted_words><&a>."
            - case string:
                - if <[text].if_null[NULL]> == NULL || <[text]> == REMOVE:
                    - narrate <script[cfg_claims_flags].parsed_key[flags.<[flag]>.deleteMsg]>
                    - flag <cuboid[<[global_id]>]> claim.flags.<[flag]>:NULL
                    - stop
                - if <script[cfg_claims_flags].data_key[flags.<[flag]>.max].exists>:
                    - define text <[text].proc[colors_parse_chat]>
                    - define min <script[cfg_claims_flags].data_key[flags.<[flag]>.min]>
                    - define max <script[cfg_claims_flags].data_key[flags.<[flag]>.max]>
                    - if <[text].strip_color.length> < <[min]>:
                        - narrate "<&[red]>The title <&[yellow]><[text]><&[red]> is too short. <&[lightgrey]>( <[min]> Characters Minimum )"
                        - stop
                    - if <[text].strip_color.length> > <[max]>:
                        - narrate "<&[red]>The title <&[yellow]><[text]><&[red]> is too long. <&[lightgrey]>( <[max]> Characters Maximum )"
                        - stop
                    - foreach <[text].strip_color.split> as:word:
                        - if !<[word].to_lowercase.regex_matches[^[a-z0-9-_]+$]>:
                            - narrate "<&[red]>Bad character detected in <&[yellow]><[word]><&[red]>, please use letters, numbers, and underscores only."
                            - stop
                        - if <[word].proc[filter_is_offensive]>:
                            - narrate "<&[red]>The word <&[yellow]><[word]><&[red]> is considered offensive, these are prohibited by the server."
                            - stop
                        - if <[word].proc[filter_is_explicit]>:
                            - narrate "<&[red]>Profane and explicit words are prohibited."
                            - stop
                - narrate "<script[cfg_claims_flags].parsed_key[flags.<[flag]>.editmsg]> <[text].parse_color.proc[colors_parse_chat]>"
                - flag <cuboid[<[global_id]>]> claim.flags.<[flag]>:<[text]>