Paste #11685: Edit of P#11683 Denizen mail system

Date: 2014/11/28 22:52:21 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"lumimails":
  type: world
  debug: false
  events:
    on mail command:
    - inject locally 'path:lumimailer'
    on mails command:
    - inject locally 'path:lumimailer'
    on lumimail command:
    - inject locally 'path:lumimailer'
    on lumimails command:
    - inject locally 'path:lumimailer'
  lumimailer:
    - if <context.args.get[1]> == send || <context.args.get[1]> == new || <context.args.get[1]> == create {
      - if <player.has_flag[<player.name>ismuted]> {
        - narrate "<&c>You can't do this when muted."
        - determine fulfilled
        - queue clear
        }
      - if <context.args.get[2]> == null {
        - narrate "<&c>Please specify a player or a group!"
        - narrate "<&c>/lumimail send [player/g:group] [message]"
        - determine fulfilled
        - queue clear
        }
      - if '<context.args.get[2].starts_with[g:]>' {
        - if <player.has_permission[lumimails.groupmail]> {
          - define grouptype '<context.args.get[2].replace[g:]>'
          - foreach <server.list_players> {
            - if <%value%.in_group[%grouptype%]> {
              - if <%value%.is_online> run tellmail as:<%value%>
              - if <%value%f.flag[lumimails].as_list> !contains '<&e><player.name>-<&6> <context.args.get[3].to[500].replace[li@].replace[|].with[ ]>' flag %value% 'LUMIMAILS:->:<&e><player.name>-<&6> <context.args.get[3].to[500].replace[li@].replace[|].with[ ]>'
              }
            }
          - narrate "<&6>You sent your mail to all players in the group <&e>%grouptype%"
          } else {
          - narrate "<&c>You do not have the permission to do this."
          }
        } else if <context.args.get[2]> == 'all' {
        - if <player.has_permission[lumimails.groupmail]> {
          - foreach <server.list_players> {
            - if <%value%.is_online> run tellmail as:<%value%>
            - if <%value%f.flag[lumimails].as_list> !contains '<&e><player.name>-<&6> <context.args.get[3].to[500].replace[li@].replace[|].with[ ]>' flag %value% 'LUMIMAILS:->:<&e><player.name>-<&6> <context.args.get[3].to[500].replace[li@].replace[|].with[ ]>'
            }
          - narrate "<&6>You sent your mail to all players that have been on this server before."
          } else {
          - narrate "<&c>You do not have the permission to do this."
          }
        } else {
        - define player <context.args.get[2]>
        - if <server.list_players> contains <p@%player%> {
          - if <p@<%player%.is_online>> run tellmail as:p@%player%
          - flag p@%player% 'LUMIMAILS:->:<&e><player.name>-<&6> <context.args.get[3].to[500].replace[li@].replace[|].with[ ]>'
          - narrate "<&6>You sent your mail to <&e>%player%."
          } else {
          - narrate "<&e>%player%<&c> has not been on this server before."
          }
        }
      } else if <context.args.get[1]> == read || <context.args.get[1]> == view {
        - if <player.flag[LUMIMAILS].as_list.size> !> 0 || <player.flag[LUMIMAILS]> == null {
          - narrate "<&6>You have no mails in your inbox."
          } else {
          - define mailnumber <context.args.get[2]||1>
          - if %mailnumber% == null {
            - define currentmail <player.flag[LUMIMAILS].as_list.get[1]>
            } else if %mailnumber% != 0 && '<m:%mailnumber%>' == 0.0 {
            - narrate "<&c>Please specify which mail you want to read with a number!"
            - narrate "<&c>/lumimail read [<&ns>]"
            - determine fulfilled
            - queue clear
            } else if %mailnumber% !> <player.flag[LUMIMAILS].as_list.size> {
            - define currentmail <player.flag[LUMIMAILS].as_list.get[%mailnumber%]>
            } else {
            - narrate "<&6>You don't have that many mails in your inbox!"
            - determine fulfilled
            - queue clear
            }
          - narrate '<&6>%currentmail%'
          - run scoreboardmailviewer def:%mailnumber%|<el@val[%currentmail%].strip_color>
          }
      } else if <context.args.get[1]> == list || <context.args.get[1]> == inbox {
        - if <player.flag[LUMIMAILS].as_list.size> > 8 {
          - define lumimaillistcounter 1
          - narrate "<&6>You have <player.flag[LUMIMAILS].as_list.size> mails in your inbox."
          - run scoreboardmaillist def:<player.flag[LUMIMAILS].as_list.size>
          - foreach <player.flag[LUMIMAILS].as_list.get[1].to[9]> {
            - narrate "<&6>%lumimaillistcounter%<&co> <el@val[%value%].substring[1,35]>..."
            - define lumimaillistcounter <el@val[<m:%lumimaillistcounter%+1>].as_int>
            }
          - narrate "<&6>And <player.flag[LUMIMAILS].as_list.size.sub[9].as_int> more."
          } else if <player.flag[LUMIMAILS]> == null {
          - narrate "<&6>You have no mails in your inbox."
          } else {
          - define lumimaillistcounter 1
          - narrate "<&6>You have <player.flag[LUMIMAILS].as_list.size> mails in your inbox."
          - foreach <player.flag[LUMIMAILS].as_list> {
            - narrate "<&6>%lumimaillistcounter%<&co> <el@val[%value%].substring[1,35]>..."
            - define lumimaillistcounter <el@val[<m:%lumimaillistcounter%+1>].as_int>
            }
          - run scoreboardmaillist def:<player.flag[LUMIMAILS].as_list.size>
          }
      } else if <context.args.get[1]> == clear || <context.args.get[1]> == delete || <context.args.get[1]> == inbox {
        - define mailnumber <context.args.get[2]>
        - if %mailnumber% == null {
          - flag LUMIMAILS:!
          - narrate "<&6>You cleared your inbox."
          - run removescoreboardwithcheck def:<player.name>maillist as:<player>
          } else if %mailnumber% != 0 && '<m:%mailnumber%>' == 0.0 {
          - flag LUMIMAILS:!
          - narrate "<&6>You cleared your inbox."
          - run removescoreboardwithcheck def:<player.name>maillist as:<player>
          } else {
          - define deletingmail '<player.flag[LUMIMAILS].as_list.get[%mailnumber%]>'
          - narrate %deletingmail%
          - flag 'LUMIMAILS:<-:%deletingmail%'
          - narrate "<&6>You removed mail %mailnumber% from your inbox."
          - run removescoreboardwithcheck def:<player.name>mail%mailnumber%
          - run scoreboardmaillist def:<player.flag[LUMIMAILS].as_list.size>
          }
      } else {
      - narrate "<&6>/mail send [player] [message]"
      - narrate "<&6>/mail list"
      - narrate "<&6>/mail read [<&ns>]"
      - narrate "<&6>/mail clear (<&ns>)"
    - determine fulfilled
"lumimailsupdater":
  type: world
  debug: false
  events:
    on player logs in:
    - run tellmail as:<player> delay:5s
"tellmail":
  type: task
  debug: false
  script:
    - wait 2
    - ^narrate "<&6>================================================="
    - ^narrate "<&e>You have <t[<player.has_flag[lumimails]>]:<player.flag[lumimails].as_list.size>||no> mail<t[<player.flag[lumimails].as_list.size.is[MORE].than[1]>]:s||> in your inbox!"
    - narrate "<&6>================================================="