Paste #117022: Unnamed Denizen Script Paste

Date: 2023/11/01 15:24:31 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# Command to be run in-game to teleport a group of players in one place to another
teleport_command:
    type: command
    name: groupTP
    aliases:
        - gtp
        - groupteleport
        - teleportgroup
    permission: groupteleport.teleport
    description: Teleports a group of players within a predefined area to another predefined area
    usage: /groupTP (posA) (posB)
    tab completions:
        # Lists all valid cuboid locations
        1: <util.notes[cuboids].replace_text[cu@]>
        2: <util.notes[cuboids].replace_text[cu@]><util.notes[locations].replace_text[li@l@]>
    script:
        - define util_cuboid_list <util.notes[cuboids]>
        # Checks command provided had correct amount of arguements to be valid
        - if <context.args.size> == 2:
            # Defines the cuboids and catches if they are incorrectly named
            - define notableA <cuboid[<context.args.get[1]>].if_null[null]>
            - define notableB <cuboid[<context.args.get[2]>].if_null[null]>
            # If notableB was a location
            - define notableBlocation <location[<context.args.get[2]>].if_null[null]>
            # If first location is invalid
            - if <[notableA]> == null:
                # If both locations are invalid
                - if <[notableB]> == null:
                    - narrate "Neither location exist!"

                # If only first location is invalid
                - else:
                    - narrate "Your first location doesn't exist!"
            # If first location is valid
            - else:
                - if <[notableB]> == null:
                    - if <[notableBlocation]> == null:
                        # If second location is invalid
                        - narrate "Your second location doesn't exist!"
                    - else:
                        - teleport <[notableA].players> <[notableBlocation].as[Location]>
                        - narrate 'Players teleported to location'
                # If both locations are valid and the command is properly syntaxed
                - else:
                    - teleport <[notableA].players> <[notableB].center>
                    - narrate 'Players teleported to cuboid'
                    # Teleports all players within arg1 to arg2 cuboids centre

        # Provided too many or too few arguements
        - else:
            - narrate 'Incorrect amount of arguements!'

gui_cuboid:
    type: item
    material: black_wool
    lore:
        - <&3> Cuboid

group_server_tp_gui:
  type: inventory
  inventory: chest
  size: 27
  gui: true
  procedural items:
    - define num_cuboids <util.notes[cuboids].size>
    - repeat <[num_cuboids]> as:n:
        - define cuboid <item[gui_cuboid]>


        - define num_cuboids_list:->:<[cuboid].with_flag[cuboid:<[n]>]>
    - determine <[num_cuboids_list]>

group_server_tp_clicked:
  type: world
  events:
    on player clicks item_flagged:cuboid in group_server_tp_gui:
        - define cuboidItem <context.item>
        - define notableA cuboid<[cuboidItem]>
        - narrate <[notableA]>