@expcluster/legacy 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/dist/browser/package.json +40 -0
- package/dist/browser/tsconfig.browser.tsbuildinfo +1 -0
- package/dist/browser/web/index.d.ts +1 -0
- package/dist/browser/web/index.d.ts.map +1 -0
- package/dist/browser/web/index.js +2 -0
- package/dist/browser/web/index.js.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +10 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/instance.d.ts +4 -0
- package/dist/node/instance.d.ts.map +1 -0
- package/dist/node/instance.js +8 -0
- package/dist/node/instance.js.map +1 -0
- package/dist/node/tsconfig.node.tsbuildinfo +1 -0
- package/dist/web/manifest.json +7 -0
- package/dist/web/static/exp_legacy.9b6538559ed5e689539c.js +355 -0
- package/dist/web/static/index_ts.8f9d451c8d3f7f293da6.js +22 -0
- package/dist/web/static/main.94e1b48804112ca8bdfc.js +118 -0
- package/dist/web/static/package_json.a83729efdb0697b12396.js +22 -0
- package/dist/web/static/web_index_tsx.e5a01ac0e4b0a6f6517f.js +21 -0
- package/index.ts +8 -0
- package/instance.ts +7 -0
- package/module/config/_file_loader.lua +29 -0
- package/module/config/advanced_start.lua +112 -0
- package/module/config/afk_kick.lua +14 -0
- package/module/config/bonus.lua +105 -0
- package/module/config/chat_reply.lua +136 -0
- package/module/config/compilatron.lua +25 -0
- package/module/config/death_logger.lua +15 -0
- package/module/config/deconlog.lua +11 -0
- package/module/config/discord_alerts.lua +25 -0
- package/module/config/expcore/permission_groups.lua +143 -0
- package/module/config/graftorio.lua +7 -0
- package/module/config/gui/autofill.lua +129 -0
- package/module/config/gui/player_list_actions.lua +201 -0
- package/module/config/gui/rockets.lua +47 -0
- package/module/config/gui/science.lua +21 -0
- package/module/config/gui/tasks.lua +13 -0
- package/module/config/gui/warps.lua +52 -0
- package/module/config/inventory_clear.lua +9 -0
- package/module/config/join_messages.lua +8 -0
- package/module/config/lawnmower.lua +6 -0
- package/module/config/logging.lua +30 -0
- package/module/config/miner.lua +8 -0
- package/module/config/module.lua +86 -0
- package/module/config/nukeprotect.lua +30 -0
- package/module/config/pollution_grading.lua +9 -0
- package/module/config/popup_messages.lua +10 -0
- package/module/config/preset_player_colours.lua +33 -0
- package/module/config/preset_player_quickbar.lua +6 -0
- package/module/config/protection.lua +17 -0
- package/module/config/repair.lua +8 -0
- package/module/config/research.lua +179 -0
- package/module/config/scorched_earth.lua +116 -0
- package/module/config/spawn_area.lua +255 -0
- package/module/config/station_auto_name.lua +11 -0
- package/module/config/statistics.lua +46 -0
- package/module/config/vlayer.lua +180 -0
- package/module/config/warnings.lua +38 -0
- package/module/control.lua +46 -0
- package/module/expcore/datastore.lua +884 -0
- package/module/expcore/external.lua +146 -0
- package/module/expcore/permission_groups.lua +355 -0
- package/module/expcore/player_data.lua +152 -0
- package/module/locale/en/addons.cfg +31 -0
- package/module/locale/en/data.cfg +114 -0
- package/module/locale/en/expcore.cfg +16 -0
- package/module/locale/en/gui.cfg +114 -0
- package/module/locale/zh-CN/addons.cfg +31 -0
- package/module/locale/zh-CN/data.cfg +114 -0
- package/module/locale/zh-CN/expcore.cfg +16 -0
- package/module/locale/zh-CN/gui.cfg +122 -0
- package/module/locale/zh-TW/addons.cfg +31 -0
- package/module/locale/zh-TW/data.cfg +114 -0
- package/module/locale/zh-TW/expcore.cfg +16 -0
- package/module/locale/zh-TW/gui.cfg +122 -0
- package/module/module.json +14 -0
- package/module/module_exports.lua +3 -0
- package/module/modules/control/jail.lua +119 -0
- package/module/modules/control/protection.lua +204 -0
- package/module/modules/control/reports.lua +225 -0
- package/module/modules/control/spectate.lua +173 -0
- package/module/modules/control/vlayer.lua +807 -0
- package/module/modules/control/warnings.lua +331 -0
- package/module/modules/control/warps.lua +488 -0
- package/module/modules/data/alt-view.lua +26 -0
- package/module/modules/data/greetings.lua +45 -0
- package/module/modules/data/language.lua +21 -0
- package/module/modules/data/player-colours.lua +63 -0
- package/module/modules/data/quickbar.lua +72 -0
- package/module/modules/data/statistics.lua +181 -0
- package/module/modules/data/tag.lua +82 -0
- package/module/modules/data/toolbar.lua +31 -0
- package/module/modules/graftorio/forcestats.lua +196 -0
- package/module/modules/graftorio/general.lua +63 -0
- package/module/modules/graftorio/require.lua +28 -0
- package/module/modules/graftorio/statics.lua +36 -0
- package/module/modules/gui/vlayer.lua +547 -0
- package/module/modules/gui/warp-list.lua +909 -0
- package/module/utils/event.lua +86 -0
- package/package.json +38 -0
- package/tsconfig.browser.json +4 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +5 -0
- package/web/index.tsx +0 -0
- package/webpack.config.js +29 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
--[[-- Control Module - Warnings
|
|
2
|
+
- Adds a way to give and remove warnings to players.
|
|
3
|
+
@control Warnings
|
|
4
|
+
@alias Warnings
|
|
5
|
+
|
|
6
|
+
@usage
|
|
7
|
+
-- import the module from the control modules
|
|
8
|
+
local Warnings = require("modules.exp_legacy.modules.control.warnings") --- @dep modules.control.warnings
|
|
9
|
+
|
|
10
|
+
-- This will add a warning to the player
|
|
11
|
+
Warnings.add_warning('MrBiter', 'Cooldude2606', 'Killed too many biters')
|
|
12
|
+
|
|
13
|
+
-- This will remove a warning from a player, second name is just who is doing the action
|
|
14
|
+
Warnings.remove_warning('MrBiter', 'Cooldude2606')
|
|
15
|
+
|
|
16
|
+
-- Script warning as similar to normal warning but are designed to have no effect for a short amount of time
|
|
17
|
+
-- this is so it can be used for greifer protection without being too agressive
|
|
18
|
+
Warnings.add_script_warning('MrBiter', 'Killed too many biters')
|
|
19
|
+
|
|
20
|
+
-- Both normal and script warnings can also be cleared, this will remove all warnings
|
|
21
|
+
Warnings.clear_warnings('MrBiter', 'Cooldude2606')
|
|
22
|
+
]]
|
|
23
|
+
|
|
24
|
+
local Event = require("modules/exp_legacy/utils/event")
|
|
25
|
+
local Storage = require("modules/exp_util/storage")
|
|
26
|
+
local config = require("modules.exp_legacy.config.warnings")
|
|
27
|
+
|
|
28
|
+
local valid_player = function(p) return type(p) == "userdata" and p or game.get_player(p) end
|
|
29
|
+
|
|
30
|
+
--- Stores the quickbar filters for a player
|
|
31
|
+
local PlayerData = require("modules.exp_legacy.expcore.player_data") --- @dep expcore.player_data
|
|
32
|
+
local PlayerWarnings = PlayerData.Required:combine("Warnings")
|
|
33
|
+
PlayerWarnings:set_metadata{
|
|
34
|
+
stringify = function(value)
|
|
35
|
+
if not value then return "You have no warnings" end
|
|
36
|
+
local count = 0
|
|
37
|
+
for _ in pairs(value) do count = count + 1 end
|
|
38
|
+
|
|
39
|
+
return "You have " .. count .. " warnings"
|
|
40
|
+
end,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
local Warnings = {
|
|
44
|
+
user_warnings = PlayerWarnings,
|
|
45
|
+
user_script_warnings = {},
|
|
46
|
+
events = {
|
|
47
|
+
--- When a warning is added to a player
|
|
48
|
+
-- @event on_warning_added
|
|
49
|
+
-- @tparam number player_index the index of the player who recived the warning
|
|
50
|
+
-- @tparam string by_player_name the name of the player who gave the warning
|
|
51
|
+
-- @tparam string reason the reason that the player was given a warning
|
|
52
|
+
-- @tparam number warning_count the new number of warnings that the player has
|
|
53
|
+
on_warning_added = script.generate_event_name(),
|
|
54
|
+
--- When a warning is removed from a player
|
|
55
|
+
-- @event on_warning_removed
|
|
56
|
+
-- @tparam number player_index the index of the player who is having the warning removed
|
|
57
|
+
-- @tparam string warning_by_name the name of the player who gave the warning
|
|
58
|
+
-- @tparam string removed_by_name the name of the player who is removing the warning
|
|
59
|
+
-- @tparam number warning_count the new number of warnings that the player has
|
|
60
|
+
-- @tparam number batch_count the number of warnings removed in this batch, always one when not a batch
|
|
61
|
+
-- @tparam number batch the index of this event in a batch, always one when not a batch
|
|
62
|
+
on_warning_removed = script.generate_event_name(),
|
|
63
|
+
--- When a warning is added to a player, by the script
|
|
64
|
+
-- @event on_script_warning_added
|
|
65
|
+
-- @tparam number player_index the index of the player who recived the warning
|
|
66
|
+
-- @tparam string reason the reason that the player was given a warning
|
|
67
|
+
-- @tparam number warning_count the new number of warnings that the player has
|
|
68
|
+
on_script_warning_added = script.generate_event_name(),
|
|
69
|
+
--- When a warning is removed from a player, by the script
|
|
70
|
+
-- @event on_script_warning_removed
|
|
71
|
+
-- @tparam number player_index the index of the player who is having the warning removed
|
|
72
|
+
-- @tparam number warning_count the new number of warnings that the player has
|
|
73
|
+
on_script_warning_removed = script.generate_event_name(),
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
local user_script_warnings = Warnings.user_script_warnings
|
|
78
|
+
Storage.register(user_script_warnings, function(tbl)
|
|
79
|
+
Warnings.user_script_warnings = tbl
|
|
80
|
+
user_script_warnings = tbl
|
|
81
|
+
end)
|
|
82
|
+
|
|
83
|
+
--- Gets an array of warnings that the player has, always returns a list even if empty
|
|
84
|
+
-- @tparam LuaPlayer player the player to get the warning for
|
|
85
|
+
-- @treturn table an array of all the warnings on this player, contains tick, by_player_name and reason
|
|
86
|
+
function Warnings.get_warnings(player)
|
|
87
|
+
return PlayerWarnings:get(player.name, {})
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
--- Gets the number of warnings that a player has on them
|
|
91
|
+
-- @tparam LuaPlayer player the player to count the warnings for
|
|
92
|
+
-- @treturn number the number of warnings that the player has
|
|
93
|
+
function Warnings.count_warnings(player)
|
|
94
|
+
local warnings = PlayerWarnings:get(player.name, {})
|
|
95
|
+
return #warnings
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
--- Adds a warning to a player, when a warning is added a set action is done based on the number of warnings and the config file
|
|
99
|
+
-- @tparam LuaPlayer player the player to add a warning to
|
|
100
|
+
-- @tparam string by_player_name the name of the player who is doing the action
|
|
101
|
+
-- @tparam[opt='Non given.'] string reason the reason that the player is being warned
|
|
102
|
+
-- @treturn number the number of warnings that the player has
|
|
103
|
+
function Warnings.add_warning(player, by_player_name, reason)
|
|
104
|
+
player = valid_player(player)
|
|
105
|
+
if not player then return end
|
|
106
|
+
if not by_player_name then return end
|
|
107
|
+
|
|
108
|
+
reason = reason or "None given."
|
|
109
|
+
|
|
110
|
+
local warning_count --- @type number
|
|
111
|
+
PlayerWarnings:update(player.name, function(_, warnings)
|
|
112
|
+
local warning = {
|
|
113
|
+
by_player_name = by_player_name,
|
|
114
|
+
reason = reason,
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if not warnings then
|
|
118
|
+
warning_count = 1
|
|
119
|
+
return { warning }
|
|
120
|
+
else
|
|
121
|
+
table.insert(warnings, warning)
|
|
122
|
+
warning_count = #warnings
|
|
123
|
+
end
|
|
124
|
+
end)
|
|
125
|
+
|
|
126
|
+
script.raise_event(Warnings.events.on_warning_added, {
|
|
127
|
+
name = Warnings.events.on_warning_added,
|
|
128
|
+
tick = game.tick,
|
|
129
|
+
player_index = player.index,
|
|
130
|
+
warning_count = warning_count,
|
|
131
|
+
by_player_name = by_player_name,
|
|
132
|
+
reason = reason,
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
local action = config.actions[warning_count]
|
|
136
|
+
if action then
|
|
137
|
+
local _type = type(action)
|
|
138
|
+
if _type == "function" then
|
|
139
|
+
action(player, by_player_name, warning_count)
|
|
140
|
+
elseif _type == "table" then
|
|
141
|
+
local current = table.deepcopy(action)
|
|
142
|
+
table.insert(current, 2, by_player_name)
|
|
143
|
+
table.insert(current, 3, warning_count)
|
|
144
|
+
player.print(current)
|
|
145
|
+
elseif type(action) == "string" then
|
|
146
|
+
player.print(action)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
return warning_count
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
--- Event trigger for removing a waring due to it being looped in clear warnings
|
|
154
|
+
-- @tparam LuaPlayer player the player who is having a warning removed
|
|
155
|
+
-- @tparam string warning_by_name the name of the player who made the warning
|
|
156
|
+
-- @tparam string removed_by_name the name of the player who is doing the action
|
|
157
|
+
-- @tparam number warning_count the number of warnings that the player how has
|
|
158
|
+
-- @tparam number batch the index of this event in a batch, always one when not a batch
|
|
159
|
+
-- @tparam number batch_count the number of reports removed in this batch, always one when not a batch
|
|
160
|
+
local function warning_removed_event(player, warning_by_name, removed_by_name, warning_count, batch, batch_count)
|
|
161
|
+
script.raise_event(Warnings.events.on_warning_removed, {
|
|
162
|
+
name = Warnings.events.on_warning_removed,
|
|
163
|
+
tick = game.tick,
|
|
164
|
+
player_index = player.index,
|
|
165
|
+
warning_count = warning_count,
|
|
166
|
+
warning_by_name = warning_by_name,
|
|
167
|
+
removed_by_name = removed_by_name,
|
|
168
|
+
batch_count = batch_count or 1,
|
|
169
|
+
batch = batch or 1,
|
|
170
|
+
})
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
--- Removes a warning from a player, always removes the earliest warning, fifo
|
|
174
|
+
-- @tparam LuaPlayer player the player to remove a warning from
|
|
175
|
+
-- @tparam string by_player_name the name of the player who is doing the action
|
|
176
|
+
-- @treturn number the number of warnings that the player has
|
|
177
|
+
function Warnings.remove_warning(player, by_player_name)
|
|
178
|
+
player = valid_player(player)
|
|
179
|
+
if not player then return end
|
|
180
|
+
if not by_player_name then return end
|
|
181
|
+
|
|
182
|
+
local warning, warning_count
|
|
183
|
+
PlayerWarnings:update(player.name, function(_, warnings)
|
|
184
|
+
if not warnings then return end
|
|
185
|
+
warning = table.remove(warnings, 1)
|
|
186
|
+
warning_count = #warnings
|
|
187
|
+
end)
|
|
188
|
+
|
|
189
|
+
if not warning then return end
|
|
190
|
+
warning_removed_event(player, warning.by_player_name, by_player_name, warning_count)
|
|
191
|
+
|
|
192
|
+
return warning_count
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
--- Removes all warnings from a player, will trigger remove event for each warning
|
|
196
|
+
-- @tparam LuaPlayer player the player to clear the warnings from
|
|
197
|
+
-- @tparam string by_player_name the name of the player who is doing the action
|
|
198
|
+
-- @treturn boolean true when warnings were cleared succesfully
|
|
199
|
+
function Warnings.clear_warnings(player, by_player_name)
|
|
200
|
+
player = valid_player(player)
|
|
201
|
+
if not player then return end
|
|
202
|
+
if not by_player_name then return end
|
|
203
|
+
|
|
204
|
+
local warnings = PlayerWarnings:get(player)
|
|
205
|
+
if not warnings then return end
|
|
206
|
+
|
|
207
|
+
local warning_count = #warnings
|
|
208
|
+
for n, warning in pairs(warnings) do
|
|
209
|
+
warning_removed_event(player, warning.by_player_name, by_player_name, warning_count - n, n, warning_count)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
PlayerWarnings:remove(player)
|
|
213
|
+
return true
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
--- Gets an array of all the script warnings that a player has
|
|
217
|
+
-- @tparam LuaPlayer player the player to get the script warnings of
|
|
218
|
+
-- @treturn table a table of all the script warnings a player has, contains tick and reason
|
|
219
|
+
function Warnings.get_script_warnings(player)
|
|
220
|
+
return user_script_warnings[player.name] or {}
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
--- Gets the number of script warnings that a player has on them
|
|
224
|
+
-- @tparam LuaPlayer player the player to count the script warnings of
|
|
225
|
+
-- @treturn number the number of script warnings that the player has
|
|
226
|
+
function Warnings.count_script_warnings(player)
|
|
227
|
+
local warnings = user_script_warnings[player.name] or {}
|
|
228
|
+
return #warnings
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
--- Adds a script warning to a player, this may add a full warning if max script warnings is met
|
|
232
|
+
-- @tparam LuaPlayer player the player to add a script warning to
|
|
233
|
+
-- @tparam[opt='Non given.'] string reason the reason that the player is being warned
|
|
234
|
+
-- @treturn number the number of script warnings that the player has
|
|
235
|
+
function Warnings.add_script_warning(player, reason)
|
|
236
|
+
player = valid_player(player)
|
|
237
|
+
if not player then return end
|
|
238
|
+
|
|
239
|
+
reason = reason or "Non given."
|
|
240
|
+
|
|
241
|
+
local warnings = user_script_warnings[player.name]
|
|
242
|
+
if not warnings then
|
|
243
|
+
warnings = {}
|
|
244
|
+
user_script_warnings[player.name] = warnings
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
table.insert(warnings, {
|
|
248
|
+
tick = game.tick,
|
|
249
|
+
reason = reason,
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
local warning_count = #warnings
|
|
253
|
+
|
|
254
|
+
script.raise_event(Warnings.events.on_script_warning_added, {
|
|
255
|
+
name = Warnings.events.on_script_warning_added,
|
|
256
|
+
tick = game.tick,
|
|
257
|
+
player_index = player.index,
|
|
258
|
+
warning_count = warning_count,
|
|
259
|
+
reason = reason,
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
if warning_count > config.script_warning_limit then
|
|
263
|
+
Warnings.add_warning(player, "<server>", reason)
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
return warning_count
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
--- Script warning removed event trigger due to it being looped in clear script warnings
|
|
270
|
+
-- @tparam LuaPlayer player the player who is having a script warning removed
|
|
271
|
+
-- @tparam number warning_count the number of warnings that the player has
|
|
272
|
+
local function script_warning_removed_event(player, warning_count)
|
|
273
|
+
script.raise_event(Warnings.events.on_script_warning_removed, {
|
|
274
|
+
name = Warnings.events.on_script_warning_removed,
|
|
275
|
+
tick = game.tick,
|
|
276
|
+
player_index = player.index,
|
|
277
|
+
warning_count = warning_count,
|
|
278
|
+
})
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
--- Removes a script warning from a player
|
|
282
|
+
-- @tparam LuaPlayer player the player to remove a script warning from
|
|
283
|
+
-- @treturn number the number of script warnings that the player has
|
|
284
|
+
function Warnings.remove_script_warning(player)
|
|
285
|
+
player = valid_player(player)
|
|
286
|
+
if not player then return end
|
|
287
|
+
|
|
288
|
+
local warnings = user_script_warnings[player.name]
|
|
289
|
+
if not warnings then return end
|
|
290
|
+
|
|
291
|
+
table.remove(warnings, 1)
|
|
292
|
+
|
|
293
|
+
script_warning_removed_event(player)
|
|
294
|
+
|
|
295
|
+
return #warnings
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
--- Removes all script warnings from a player, emits event for each warning removed
|
|
299
|
+
-- @tparam LuaPlayer player the player to clear the script warnings from
|
|
300
|
+
function Warnings.clear_script_warnings(player)
|
|
301
|
+
player = valid_player(player)
|
|
302
|
+
if not player then return end
|
|
303
|
+
|
|
304
|
+
local warnings = user_script_warnings[player.name]
|
|
305
|
+
if not warnings then return end
|
|
306
|
+
|
|
307
|
+
local warning_count = #warnings
|
|
308
|
+
for n, _ in pairs(warnings) do
|
|
309
|
+
script_warning_removed_event(player, warning_count - n)
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
user_script_warnings[player.name] = nil
|
|
313
|
+
return true
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
-- script warnings are removed after a certain amount of time to make them even more lienient
|
|
317
|
+
local script_warning_cool_down = config.script_warning_cool_down * 3600
|
|
318
|
+
Event.on_nth_tick(script_warning_cool_down / 4, function()
|
|
319
|
+
local cutoff = game.tick - script_warning_cool_down
|
|
320
|
+
for player_name, script_warnings in pairs(user_script_warnings) do
|
|
321
|
+
if #script_warnings > 0 then
|
|
322
|
+
for _, warning in pairs(script_warnings) do
|
|
323
|
+
if warning.tick < cutoff then
|
|
324
|
+
Warnings.remove_script_warning(player_name)
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
end)
|
|
330
|
+
|
|
331
|
+
return Warnings
|