Date: 2018/07/23 23:02:41 UTC-07:00
Type: Denizen 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
#########################################
# STAFF MANAGEMENT COMMANDS AND HANDLER #
#########################################
Staff_Management:
type: world
debug: false
events:
on demote command:
- if <player.is_op>.not {
- queue clear
}
- determine passively fulfilled
- run Staff_Management_Task instantly def:demote|currently|<context.args>
on promote command:
- if <player.is_op>.not {
- queue clear
}
- determine passively fulfilled
- run Staff_Management_Task instantly def:promote|not|<context.args>
Staff_Management_Task:
type: task
debug: false
failure:
- narrate "<&c>You must specify a player who is <def[2]> part of the staff team."
- narrate "<&f> e.g. /<def[1]> Gleavie09"
script:
- if <player.is_op> || <player.has_flag[owner]> {
- determine passively fulfilled
- if <def[3].size> == 0 {
- inject locally failure instantly
} else if <def[3].size> > 1 {
- narrate "<&c>Too many arguments!"
- narrate "<&f> e.g. /<def[1]> Gleavie09"
} else {
- define message <def[3].get[1]>
- if <def[1]> == demote {
- if <def[message].as_player.has_flag[staff]||false> {
- flag <def[message].as_player> staff:!
- narrate target:<def[message].as_player> "<&4>You have been removed from the staff team. Returning to survival mode and setting chat to <&2>Local<&4>."
- flag <def[message].as_player> chat_channel:local
- execute as_server "gamemode survival <def[message]>"
- narrate "<&a>Successfully demoted <def[message]>"
} else {
- inject locally failure instantly
}
} else if <def[1]> == promote {
- if <def[message].as_player.has_flag[staff].not||false> {
- flag <def[message].as_player> staff
- narrate target:<def[message].as_player> "<&a>You have been added to the <&4>Staff <&a>team! You may now access the <&4>Staff <&a>chat channel using the /staff command."
- narrate "<&a>Successfully promoted <def[message]>"
} else {
- inject locally failure instantly
}
}
}
}
#############################################################
# CHAT CHANNELS - NOTE: FOR TRADE CHANNEL TO WORK, YOU MUST #
# FIRST CREATE NOTABLE REGIONS WITH THE SUFFIX _TOWN #
#############################################################
LocalChat_Format:
type: format
debug: false
format: <&2><&lb><player.name><&rb><&co> <&f><text>
GlobalChat_Format:
type: format
debug: false
format: <&7><&lb>Global<&rb> <&8><player.name><&7><&co> <&a><text>
TradeChat_Format:
type: format
debug: false
format: <&5><&lb>Trade - <player.location.cuboids.filter[contains[_town]].get[1].before[_town].after[cu@].replace[_].with[<&sp>].to_titlecase><&rb> <&d><player.name><&5><&co> <&b><text>
StaffChat_Format:
type: format
debug: false
format: <&4><&lb>Staff<&rb> <&8><player.name><&7><&co> <&f><text>
Chat_Channels:
type: world
debug: false
Local_Radius:
- 20
Global_Chat_Limit:
- 10
Global_Chat_Period:
- 1h
help:
- narrate "<&3>====== <&b>Chat Help <&3>======"
- narrate ""
- narrate " - <&l>/local <&r>For speaking to everyone in a <script.yaml_key[Local_Radius].after[li@]> block radius."
- narrate " - <&l>/global <&r><&a>Chat to everyone, limited to <script.yaml_key[Global_Chat_Limit].after[li@]> per <script.yaml_key[Global_Chat_Period].after[li@]>."
- narrate " - <&l>/trade <&r><&b>Arrange trades with others in the same city."
- narrate ""
- determine passively fulfilled
events:
on player chats:
- determine passively cancelled
- choose <player.flag[chat_channel]>:
- case global:
- if <pl.has_flag[staff].not> {
- inject GlobalChat_Monitor instantly
}
- announce format:GlobalChat_Format <c.message>
- case local:
- narrate format:LocalChat_Format <c.message> targets:<pl.location.find.players.within[<script.yaml_key[Local_Radius]>]>
- case trade:
- if <pl.location.cuboids.filter[contains[_town]].size.is[LESS].than[1]> {
- narrate "<&4>You cannot use Trade Chat unless you are in a town."
} else {
- narrate format:TradeChat_Format <c.message> targets:<pl.location.cuboids.filter[contains[_town]].get[1].list_players>
}
- case staff:
- if <pl.has_flag[staff].not> {
- flag <player> chat_channel:local
- narrate "<&c>You do not have access to this channel. Returning to <&2>Local Chat"
} else {
- narrate format:StaffChat_Format <c.message> targets:<server.list_players.filter[has_flag[staff]]>
}
on chat command:
- inject locally help
on global command:
- determine passively fulfilled
- define message <c.raw_args>
- if <c.raw_args.length.is[MORE].than[0]> {
- inject GlobalChat_Monitor instantly
- announce format:GlobalChat_Format <def[message]>
- queue clear
}
- if <player.flag[chat_channel].is[==].to[global]> {
- narrate "<&4>Your default channel is already Global Chat."
} else {
- narrate "<&3>Set your chat channel to <&8><&lb><&7>Global<&8><&rb>"
- flag player chat_channel:global
}
on trade command:
- determine passively fulfilled
- define message <c.raw_args>
- if <c.raw_args.length.is[MORE].than[0]> {
- if <pl.location.cuboids.filter[contains[_town]].size.is[LESS].than[1]> {
- narrate "<&4>You cannot use Trade Chat unless you are in a town."
} else {
- narrate format:TradeChat_Format <def[message]> targets:<pl.location.cuboids.filter[contains[_town]].get[1].list_players>
}
- queue clear
}
- if <player.flag[chat_channel].is[==].to[trade]> {
- narrate "<&4>Your default channel is already Trade Chat."
} else {
- narrate "<&3>Set your chat channel to <&8><&lb><&5>Trade<&8><&rb>"
- flag player chat_channel:trade
}
on local command:
- determine passively fulfilled
- define message <c.raw_args>
- if <c.raw_args.length.is[MORE].than[0]> {
- narrate format:LocalChat_Format <def[message]> targets:<pl.location.find.players.within[<script.yaml_key[Local_Radius]>]>
- queue clear
}
- if <player.flag[chat_channel].is[==].to[local]> {
- narrate "<&4>Your default channel is already Local."
} else {
- narrate "<&3>Set your chat channel to <&2><&lb>Local<&rb>"
- flag player chat_channel:local
}
on player joins:
- if <player.has_flag[chat_channel].not> {
- flag player chat_channel:local
}
on staff command:
- define message <c.raw_args>
- if <player.has_flag[staff].not> {
- queue clear
} else {
- determine passively fulfilled
}
- if <c.raw_args.length.is[MORE].than[0]> {
- narrate format:StaffChat_Format <def[message]> targets:<server.list_players.filter[has_flag[staff]]>
- queue clear
}
- if <player.flag[chat_channel].is[==].to[staff]> {
- narrate "<&4>Your default channel is already Staff"
} else {
- narrate "<&3>Set your chat channel to <&4><&lb>Staff<&rb>"
- flag <player> chat_channel:staff
}
GlobalChat_Monitor:
type: task
script:
- if <pl.flag[global_chat_count].is[MORE].than[9]> {
- narrate "<&4>You have reached your limit for Global Chat. Please try again later."
- queue clear
}
- flag player global_chat_count:++
- if <pl.flag[global_chat_count].is[==].to[7]> {
- narrate "<&8>Warning<&co> You may use global chat 2 more times this hour."
}
- if <pl.flag[global_chat_count].is[==].to[8]> {
- narrate "<&8>Warning<&co> You may use global chat 1 more times this hour."
}
- run GlobalChat_Decay delay:<s@Chat_Channels.yaml_key[Global_Chat_Period]> def:<player>
GlobalChat_Decay:
type: task
script:
- if <def[1].as_player.flag[global_chat_count].is[MORE].than[0]> {
- flag <def[1].as_player> global_chat_count:--
}