- 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








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Staff Pick: MOTD Manager


By Anthony
Created: 2014/12/02 06:49:41 UTC-08:00 (10 years and 22 days ago)
Edited: 2014/12/28 16:45:35 UTC-08:00 (9 years and 361 days ago)
Likes: 1

Staff pick as of: 2014/12/02 21:45:03 UTC-08:00 (10 years and 22 days ago)
Denizen Version: 0.9.5-b1522
Script Version: 1.0
Description:

M O T D M a n a g e r
A system for serving custom MOTDs


Author: |Anthony|
Version: 0.1
dScript Version: 0.9.5-b1522

Dependencies:
- ConfigFileGenerator: http://scripts.citizensnpcs.co/view/0coo5b

____________________

ABOUT:

MOTD Manager stores the IP address of players that connect to your server. It will then use this list of IP:player to check the player for a permission and send them a random message from the appropriate category when they view their server list in their client.


USAGE:

[list]
* Edit the messages.yml file that is generated on first run
[list]
* Edit the messages for the existing categories
* Create new categories if needed
* You can use denizen tags inside the messages to display dynamic content
to the viewer.
* After editing the messages.yml file you must reload the config files
/motd reload
[/list]
* Assign players the desired motd.<category> permission node.

* Reset the config file
[/list]

TODO - Future Feature Fluff:

- Add better command support
- Ability to list/view/edit/create/delete categories and messages

- Maybe make it not write to the IPlist.yml if the info is the same



Download script | View raw script
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
22700

# ---------------------------------------------------------------------------- #
#                                                                              |
#                                                                              |
#                            M O T D   M a n a g e r                           |
#                                                                              |
#                       A system for serving custom MOTDs                      |
#                                                                              |
#                                                                              |
#   Author: |Anthony|                                                          |
#   Version: 0.1                                                               |
#   dScript Version: 0.9.5-b1522                                               |
#                                                                              |
#   Dependencies:                                                              |
#   - ConfigFileGenerator:    http://scripts.citizensnpcs.co/view/0coo5b       | 
# ---------------------------------------------------------------------------- #


# ABOUT:

#   MOTD Manager stores the IP address of players that connect to your server.
# It will then use this list of IP:player to check the player for a permission
# and send them a random message from the appropriate category when they view
# their server list in their client.


# USAGE:

#  - Edit the messages.yml file that is generated on first run
#    - Edit the messages for the existing categories
#    - Create new categories if needed
#    - You can use denizen tags inside the messages to display dynamic content
#      to the viewer.
#    - After editing the messages.yml file you must reload the config files
#      /motd reload

#  - Assign players the desired motd.<category> permission node.

#  - Reset the config file


# TODO - Future Feature Fluff:
#    
#    - Add better command support
#      - Ability to list/view/edit/create/delete categories and messages

#    - Maybe make it not write to the IPlist.yml if the info is the same

#______________________________________________________________________________#


'ServerPing':
  type: world
  debug: false

  events:
    # What happens when a player (or bot) pings the server
    on server list ping:
    - inject locally ping instantly

    on player joins:
    - run locally join instantly

    on server start:
    - run locally loadYaml instantly delay:2s

    on motd command:
    - if !<context.server> {
      - if !<player.has_permission[motd.admin]> queue stop
      }
    - if <c.args.get[1].is[==].to[reload]> {
      - determine passively FULFILLED
      - run locally loadYaml instantly delay:2s
      - narrate "Configs reloaded!"
      - queue stop
      }
    - if <c.args.get[1].is[==].to[save]> {
      - determine passively FULFILLED
      - run locally save instantly def:ipList
      - run locally save instantly def:messages
      - narrate "Configs saved!"
      - queue stop
      }
    - if <c.args.get[1].is[==].to[--reset]> {
      - determine passively FULFILLED
      - flag <player> ConfigFileGeneratorNotify:true
      - run s@ConfigFileGeneratorHelper def:MOTDManager|messages|false|true|true instantly
      - flag <player> ConfigFileGeneratorNotify:!
      - run locally loadYaml instantly delay:2s
      - queue stop
      }

  ping:
    - define address '<context.address.replace[.].with[-]>'
    - define maxPlayers '<context.max_players>'
    # Do we know this IP?
    - if !<yaml[MOTDManager_ipList].contains[%address%]> {
      - define message '<parse:<yaml[MOTDManager_messages].read[messages.messages.unknown].random>>'
      - determine <def[message]>
      - queue stop
      }
    # Ok, we know this IP
    - define player '<yaml[MOTDManager_ipList].read[%address%].as_player>'
    # Is this person in the minecraft ban file?
    - if <def[player].is_banned> {
      - define message '<parse:<yaml[MOTDManager_messages].read[messages.messages.banned].random>>'
      - determine <def[message]>
      - queue stop
      }
    # Build a list of message types based on the contents of the messages.yml file
    - define messageTypes '<yaml[MOTDManager_messages].list_keys[messages.messages].exclude[unknown|banned]>'
    # Determine which category to pull a message from, then get a random message from that category.
    #  Default to unknown if they don't fit in a category
    # BUG: Stops on first success. Would rather gather all cats and rando from
    - foreach %messageTypes% {
      - if <def[player].has_permission[motd.%value%].global> {
        - define message '<parse:<yaml[MOTDManager_messages].read[messages.messages.%value%].random>>'
        - foreach stop
        }
        else {
        - define message '<parse:<yaml[MOTDManager_messages].read[messages.messages.unknown].random>>'
        }
      }
    - determine <def[message]>

  join:
    # Add the player IP as a key with the player object as the value.
    # Using the IP as the key gives us known info on server ping event BUT has
    #  the potential to have stale data since player IP is dynamic (generally).
    # This always writes, even if the node exists. If multiple people connect
    #  from the same IP, it will store the last player to connect.
    - yaml 'write:<player.ip.address.replace[.].with[-].before[<&co>]>' 'value:<player>' id:MOTDManager_ipList
    - run locally save instantly def:ipList

  loadYaml:
    # Loads the yaml files and generates default files if they don't exist.
    - announce "<&b>Loading MOTD Manager config files..." to_console
    - if !<server.has_file[MOTDManager/messages.yml]> {
      - if <player> != null {
        - flag <player> ConfigFileGeneratorNotify:true
        - run s@ConfigFileGeneratorHelper def:MOTDManager|messages|false|true|false instantly
        - flag <player> ConfigFileGeneratorNotify:!
        }
        else run s@ConfigFileGeneratorHelper def:MOTDManager|messages instantly
      }
      else {
      - if <yaml.list.contains[MOTDManager_messages]> yaml unload 'id:MOTDManager_messages'
      }
    - yaml 'load:MOTDManager/messages.yml' 'id:MOTDManager_messages'

    - if !<server.has_file[MOTDManager/ipList.yml]> {
      - yaml create 'id:MOTDManager_ipList'
      - yaml 'write:description' 'value:This file stores a list of IP addresses and the last known player UUID' id:MOTDManager_ipList
      - yaml 'savefile:MOTDManager/ipList.yml' 'id:MOTDManager_ipList'
      }
      else {
      - if <yaml.list.contains[MOTDManager_ipList]> yaml unload 'id:MOTDManager_ipList'
      }
    - yaml 'load:MOTDManager/ipList.yml' 'id:MOTDManager_ipList'
    - announce "<&b>MOTD Manager config files Loaded!" to_console

  save:
    - yaml 'savefile:MOTDManager/%1%.yml' 'id:MOTDManager_%1%'
    - yaml unload 'id:MOTDManager_%1%'
    - yaml 'load:MOTDManager/%1%.yml' 'id:MOTDManager_%1%'




################################################################################
#                                                                              #
# Messages                                                                     #
#                                                                              #
# These are the default messages. They will be used to build the messages.yml  #
#  file. You can add additional messages and categories to that file after it  #
#  has been generated.                                                         #
#                                                                              #
#______________________________________________________________________________#
#                                                                              #
#______________________________DO_NOT_EDIT_THIS_DATA___________________________#
#______________________________________________________________________________#



MOTDManager_messages:
  type: yaml data
  debug: false

# Just add new messages and permissions to check.
# The banned and unknown sections are checked outside the other types.

  messages:
    information:
      description:
        - 'Custom MOTD system'
        - 'Display a custom MOTD to players based on a permission.'
        - 'MOTD for Staff groups, player groups, or individual players.'
        - 'This file holds all the messages for the server ping event.'
      usage:
        - 'Add/change the messages in the categories below as needed.'
        - 'We can use denizen tags to add almost any information to the custom'
        - 'messages such as last login time, how much econ money they have, etc.'
        - 'Make sure players have the appropriate permission (listed below).'
        - 'You can create new categories by simply creating a new node under the'
        - 'messages node and assigning players the corresponding permission.'
      permissions:
        - 'motd.trial'
        - 'motd.member'
        - 'motd.expired'
        - 'motd.customNode'
    messages:
      unknown:
        - '<&6>We<&sq>ve never met!<&nl><&e>Here<&sq>s a Second Line!'
      banned:
        - '<&c>You have been Banned <&6><def[player].name>!<&nl><&b>Appeal your ban on the forum!'
      expired:
        - '<&6>Your membership has expired <def[player].name>!<&nl><&e>Go to the forum to renew today!'
      trial:
        - '<&6>We hope you<&sq>re enjoying yourself <&a><def[player].name>!<&nl><&e>You first joined <def[player].first_played.formatted> ago.'
      member:
        - '<&6>Welcome back <&a><def[player].name>!<&nl><&e>We<&sq>re glad to see you!'
      customNode:
        - '<&6>Hey, you<&sq>re special <&a><def[player].name>!<&nl><&e>C<&sq>mon in, the coffee is fresh!'









View History