Paste #66366: Untitled Paste

Date: 2020/03/22 14:01:54 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Holographic Titles:
  type: command
  debug: false
  name: holotitles
  description: Used to create holographic titles in the world.
  usage: /holotitles <&lb>create/remove/move/list<&rb> <&lb>title<&rb> <&lb>text<&rb>
  aliases:
  - holo
  - ht
  permission: holotitles
  permission message: <&e>Type /help for a list of commands.
  allowed help:
  - determine <player.in_group[admin]||<context.server>>
  tab complete:
  - if !<player.in_group[admin]||<context.server>>:
    - stop
  - determine <server.list_online_players.parse[name].include[create|remove|move|list].filter[starts_with[<context.args.last||>]]>
  script:
  - if !<player.in_group[admin]||<context.server>>:
    - narrate "<&e>Type /help for a list of commands."
    - stop
  - choose <context.args.get[1]>:
    - case create:
      - define title <context.args.get[2]||null>
      - define text <context.args.get[3]||null>
      - if <[title]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for title. <&nl><&b>Proper format<&co> <&7>/holo create [title] [text]"
        - stop
      - else if <[text]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for text. <&nl><&b>Proper format<&co> <&7>/holo create [title] [text]"
        - stop
      - else:
        - define textString <context.raw_args.after[<context.args.get[2]>].trim.parse_color>
        - spawn "armor_stand[custom_name_visible=true;custom_name=<[textString]>;gravity=false;visible=false]" <player.location.center.sub[0,1,0]> save:standTitle
        - yaml id:holotitles_list set <player.world.name>.<[title]>.location:<entry[standTitle].spawned_entities.get[1].location>
        - yaml id:holotitles_list set <player.world.name>.<[title]>.entityName:<entry[standTitle].spawned_entities.get[1]>
        - yaml id:holotitles_list set <player.world.name>.<[title]>.text:<[textString]>
        - yaml "savefile:/yml_saves/holotitles_list.yml" id:holotitles_list
        - narrate "<&9>Holotitles<&co> <&e>Holo title <&b><[title]> <&e>created at <player.location.center.sub[0,1,0].xyz.replace[,].with[, ]>."
    - case remove:
      - define title <context.args.get[2]||null>
      - if <[title]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for title. <&nl><&b>Proper format<&co> <&7>/holo remove [title]"
        - stop
      - else:
        - remove <yaml[holotitles_list].read[<player.world.name>.<[title]>.entityName]>
        - wait 1t
        - yaml id:holotitles_list set <player.world.name>.<[title]>:!
        - yaml "savefile:/yml_saves/holotitles_list.yml" id:holotitles_list
    - case move:
      - define title <context.args.get[2]||null>
      - define moveX <context.args.get[3]||null>
      - define moveY <context.args.get[4]||null>
      - define moveZ <context.args.get[5]||null>
      - if <[title]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for title. <&nl><&b>Proper format<&co> <&7>/holo move [title] [X] [Y] [Z]"
        - stop
      - else if <[moveX]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for title. <&nl><&b>Proper format<&co> <&7>/holo move [title] [X] [Y] [Z]"
        - stop
      - else if <[moveY]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for title. <&nl><&b>Proper format<&co> <&7>/holo move [title] [X] [Y] [Z]"
        - stop
      - else if <[moveZ]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for title. <&nl><&b>Proper format<&co> <&7>/holo move [title] [X] [Y] [Z]"
        - stop
      - else:
        - define entityID <yaml[holotitles_list].read[<player.world.name>.<[title]>.entityName]>
        - teleport <[entityID]> <[entityID].location.add[<[moveX]>,<[moveY]>,<[moveZ]>]>
        - yaml id:holotitles_list set <player.world.name>.<[title]>.location:<[entityID].location>
        - yaml "savefile:/yml_saves/holotitles_list.yml" id:holotitles_list
    - case edit:
      - define title <context.args.get[2]||null>
      - define text <context.args.get[3]||null>
      - if <[title]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for title. <&nl><&b>Proper format<&co> <&7>/holo edit [title] [text]"
        - stop
      - if !<yaml[holotitles_list].contains[<player.world.name>.<[title]>]>:
        - narrate NOPE
      - else if <[text]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for text. <&nl><&b>Proper format<&co> <&7>/holo edit [title] [text]"
        - stop
      - else:
        - define textString <context.raw_args.after[<context.args.get[2]>].trim.parse_color>
        - adjust <yaml[holotitles_list].read[<player.world.name>.<[title]>.entityName]> custom_name:<[textString]>
        - yaml id:holotitles_list set <player.world.name>.<[title]>.text:<[textString]>
        - yaml "savefile:/yml_saves/holotitles_list.yml" id:holotitles_list
        - narrate "<&9>Holotitles<&co> <&e>Holo title <&b><[title]> <&e>has been updated."
    - case list:
      - define range <context.args.get[2]||null>
      - if <[range]> == null:
        - narrate "<&9>Holotitles<&co> <&c>No value entered for range. <&nl><&b>Proper format<&co> <&7>/holo list [range]"
        - stop
      - else if !<[range].is_decimal>:
        - narrate "<&9>Holotitles<&co> <&c>Range value must be a number. <&nl><&b>Proper format<&co> <&7>/holo list [range]"
        - stop
      - else if <[range]> > 20:
        - narrate "<&9>Holotitles<&co> <&c>Range value cannot exceed 20."
      - else:
        - define none_found "<&c>No holo titles were found within the specified range."
        - foreach <yaml[holotitles_list].list_keys[<player.world.name>]> as:StandName:
          - define listX <yaml[holotitles_list].read[<player.world.name>.<[StandName]>.location].as_location.x>
          - define listY <yaml[holotitles_list].read[<player.world.name>.<[StandName]>.location].as_location.y>
          - define listZ <yaml[holotitles_list].read[<player.world.name>.<[StandName]>.location].as_location.z>
          - if <player.location.x.sub[<[listX]>].abs> <= <[range]>:
            - if <player.location.y.sub[<[listY]>].abs> <= <[range]>:
              - if <player.location.z.sub[<[listZ]>].abs> <= <[range]>:
                - define StandList:->:<[StandName]>
        - narrate "<&9>Holotitles (<&a><[range]><&9>)<&co> <&b><[StandList].comma_separated.replace[,].with[<&7>,<&b>]||<[none_found]>>"
    - case check:
      - define title <context.args.get[2]||null>
      - if <yaml[holotitles_list].contains[<player.world.name>.<[title]>]>:
        - define entity <yaml[holotitles_list].read[<player.world.name>.<[title]>.entityName].as_entity>
        - define textSave <yaml[holotitles_list].read[<player.world.name>.<[title]>.entityName].as_entity.custom_name>
        - adjust <[entity]> "custom_name:<&a>--<&gt> Current Selection<&co> <&b><[title]> <&a><&lt>--"
        - wait 10t
        - adjust <[entity]> custom_name:<[textSave]>
        - wait 10t
        - adjust <[entity]> "custom_name:<&a>--<&gt> Current Selection<&co> <&b><[title]> <&a><&lt>--"
        - wait 10t
        - adjust <[entity]> custom_name:<[textSave]>
      - else:
        - narrate "<&9>Holotitles<&co> <&c>Invalid holo title selected. <&nl><&b>Proper format<&co> <&7>/holo check [title]"
    - case help:
      - narrate Help
    - default:
      - narrate "<&c>Invalid sub-command! Type /holo help for a list of commands."

holotitles_load:
  type: world
  debug: false
  events:
    on server start:
    - yaml "load:/yml_saves/holotitles_list.yml" id:holotitles_list