Skip to content

Commit 205a809

Browse files
committed
Refactor report jail
1 parent a618cf1 commit 205a809

File tree

11 files changed

+58
-50
lines changed

11 files changed

+58
-50
lines changed

exp_legacy/module/config/_file_loader.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ return {
1111
"modules.addons.scorched-earth",
1212
"modules.addons.station-auto-name",
1313
"modules.addons.tree-decon",
14-
"modules.addons.afk-kick",
15-
"modules.addons.report-jail",
1614
"modules.addons.miner",
1715

1816
-- Control

exp_legacy/module/locale/en/addons.cfg

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,3 @@ ban=You were banned for having too many warnings; visit __1__ to request a ban a
2929
script-warning=You are receiving script warnings; if you recive too many you will receive a permanent warning (__1__/__2__)
3030
script-warning-removed=A script warning has expired (__1__/__2__)
3131
script-warning-limit=__1__ has received a permanent warning from the script.
32-
33-
[afk-kick]
34-
message=All players were kicked because everyone was AFK.
35-
36-
[report-jail]
37-
jail=__1__ was jailed because they were reported too many times. Please wait for a moderator.

exp_legacy/module/locale/zh-CN/addons.cfg

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,3 @@ ban=你已因為被警告太多次而被封禁; 可以到 __1__ 申訴.
2929
script-warning=這是系統發出的自動警告 (__1__/__2__)
3030
script-warning-removed=系統發出的自動警告已失效 (__1__/__2__)
3131
script-warning-limit=__1__ 已被系統發出了一則自動警告。
32-
33-
[afk-kick]
34-
message=因地圖中沒有活躍玩家,所以所有人都已被請離。
35-
36-
[report-jail]
37-
jail=__1__ 因被多次舉報而被禁止行動。請等候管理員作出下一步處理。

exp_legacy/module/locale/zh-TW/addons.cfg

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,3 @@ ban=你已因為被警告太多次而被封禁; 可以到 __1__ 申訴.
2929
script-warning=這是系統發出的自動警告 (__1__/__2__)
3030
script-warning-removed=系統發出的自動警告已失效 (__1__/__2__)
3131
script-warning-limit=__1__ 已被系統發出了一則自動警告。
32-
33-
[afk-kick]
34-
message=因地圖中沒有活躍玩家,所以所有人都已被請離。
35-
36-
[report-jail]
37-
jail=__1__ 因被多次舉報而被禁止行動。請等候管理員作出下一步處理。

exp_legacy/module/modules/addons/report-jail.lua

Lines changed: 0 additions & 29 deletions
This file was deleted.

exp_scenario/module/control.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ add(require("modules/exp_scenario/control/inventory_clear"))
5959
add(require("modules/exp_scenario/control/nuke_protection"))
6060
add(require("modules/exp_scenario/control/pollution_grading"))
6161
add(require("modules/exp_scenario/control/protection_jail"))
62+
add(require("modules/exp_scenario/control/report_jail"))
6263
add(require("modules/exp_scenario/control/research"))
6364

6465
--- Guis

exp_scenario/module/control/afk_kick.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ local function check_afk_players()
4848
local frame = player.gui.screen.add{
4949
type = "frame",
5050
name = "afk-kick",
51-
caption = { "afk-kick.message" },
51+
caption = { "exp_afk-kick.kick-message" },
5252
}
5353

5454
local uis = player.display_scale
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--[[-- Control - Report Jail
2+
When a player is reported, the player is automatically jailed if the combined playtime of the reporters exceeds the reported player
3+
]]
4+
5+
local ExpUtil = require("modules/exp_util")
6+
local Jail = require("modules.exp_legacy.modules.control.jail")
7+
local Reports = require("modules.exp_legacy.modules.control.reports")
8+
9+
local max = math.max
10+
local format_player_name = ExpUtil.format_player_name_locale
11+
12+
--- Returns the playtime of the reporter. Used when calculating the total playtime of all reporters
13+
--- @param player LuaPlayer
14+
--- @param by_player_name string
15+
--- @param reason string
16+
--- @return number
17+
local function reporter_playtime(player, by_player_name, reason)
18+
local by_player = game.get_player(by_player_name)
19+
return by_player and by_player.online_time or 0
20+
end
21+
22+
--- Check if the player has too many reports against them (based on playtime)
23+
local function on_player_reported(event)
24+
local player = assert(game.get_player(event.player_index))
25+
local total_playtime = Reports.count_reports(player, reporter_playtime)
26+
27+
-- Total time greater than the players own time, or 30 minutes, which ever is greater
28+
if Reports.count_reports(player) > 1 and total_playtime > max(player.online_time * 2, 108000) then
29+
Jail.jail_player(player, "<reports>", "Reported by too many players, please wait for a moderator.")
30+
game.print{ "exp_report-jail.chat-jailed", format_player_name(player) }
31+
end
32+
end
33+
34+
return {
35+
events = {
36+
[Reports.events.on_player_reported] = on_player_reported,
37+
}
38+
}

exp_scenario/module/locale/en.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ type-player=Player
376376
type-static=Static
377377
type-loop=Loop
378378
379+
[exp_afk-kick]
380+
kick-message=All players were kicked because everyone was AFK.
381+
379382
[exp_chat-auto-reply]
380383
chat-reply=[Compilatron] __1__
381384
chat-disallowed=You can't use global chat commands
@@ -429,3 +432,6 @@ chat-found=You cannot have __1__ in your inventory, so it was placed into the ch
429432
430433
[exp_protection-jail]
431434
chat-jailed=__1__ was jailed because they removed too many protected entities. Please wait for a moderator.
435+
436+
[exp_report-jail]
437+
chat-jailed=__1__ was jailed because they were reported too many times. Please wait for a moderator.

exp_scenario/module/locale/zh-CN.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ type-player=用戶
376376
type-static=靜態
377377
type-loop=循環
378378

379+
[exp_afk-kick]
380+
kick-message=因地圖中沒有活躍玩家,所以所有人都已被請離。
381+
379382
[exp_chat-auto-reply]
380383
chat-reply=[Compilatron] __1__
381384
chat-disallowed=你沒有權限使用這個指令。
@@ -429,3 +432,6 @@ chat-found=你的用戶組不允許你有 __1__ ,所以該物品已放在出
429432

430433
[exp_protection-jail]
431434
chat-jailed=__1__ 因被多次拆除受保護物體而被禁止行動。請等候管理員作出下一步處理。
435+
436+
[exp_report-jail]
437+
chat-jailed=__1__ 因被多次舉報而被禁止行動。請等候管理員作出下一步處理。

0 commit comments

Comments
 (0)