From 0c859c228b7bd3fb50b02053e2899b0f91e611de Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Mon, 5 Apr 2021 22:21:46 +0100
Subject: [PATCH 01/14] Added report jail
---
config/_file_loader.lua | 1 +
locale/en/addons.cfg | 5 ++++-
modules/addons/report-jail.lua | 25 +++++++++++++++++++++++++
3 files changed, 30 insertions(+), 1 deletion(-)
create mode 100644 modules/addons/report-jail.lua
diff --git a/config/_file_loader.lua b/config/_file_loader.lua
index 16a135af..c09715d1 100644
--- a/config/_file_loader.lua
+++ b/config/_file_loader.lua
@@ -43,6 +43,7 @@ return {
'modules.addons.discord-alerts',
'modules.addons.chat-reply',
'modules.addons.tree-decon',
+ 'modules.addons.report-jail',
--- Data
'modules.data.statistics',
diff --git a/locale/en/addons.cfg b/locale/en/addons.cfg
index 95defd53..9acd4abc 100644
--- a/locale/en/addons.cfg
+++ b/locale/en/addons.cfg
@@ -75,4 +75,7 @@ get-mead-1= Filling the drinking horn
get-mead-2= Skål!
get-beer-1= 🍺 Pouring A Glass 🍺
get-beer-2= 🍻 Chears Mate 🍻
-verify=Please return to our discord and type r!verify __1__
\ No newline at end of file
+verify=Please return to our discord and type r!verify __1__
+
+[report-jail]
+jail=__1__ was jailed because they have been reported too many times.
\ No newline at end of file
diff --git a/modules/addons/report-jail.lua b/modules/addons/report-jail.lua
new file mode 100644
index 00000000..b98c3ce0
--- /dev/null
+++ b/modules/addons/report-jail.lua
@@ -0,0 +1,25 @@
+--- When a player is reported by players with a greater combined delta playtime, the player is automatically jailed
+-- @addon report-jail
+
+local Event = require 'utils.event' ---@dep utils.event
+local Jail = require 'modules.control.jail' ---@dep modules.control.jail
+local Reports = require 'modules.control.reports' --- @dep modules.control.reports
+local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
+
+--- Returns the playtime of the reporter, used to sum the playtime of all reporters
+local function reporter_playtime(_, by_player_name, _)
+ local player = game.get_player(by_player_name)
+ if player == nil then return 0 end
+ return player.online_time
+end
+
+--- Tests the combined playtime of all reporters against the reported player
+Event.add(Reports.events.on_player_reported, function(event)
+ local player = game.get_player(event.player_index)
+ local total_playtime = Reports.count_reports(player, reporter_playtime)
+ if total_playtime < player.online_time*1.5 then return end
+ -- Combined playtime is greater than 150% of the reported's playtime
+ local player_name_color = format_chat_player_name(player)
+ Jail.jail_player(player, '', 'Reported by too many players, please wait for a moderator.')
+ game.print{'report-jail.jail', player_name_color}
+end)
\ No newline at end of file
From 5328a5bb1ca8d6bb5cde47fb28214a199f9319df Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Mon, 5 Apr 2021 22:41:04 +0100
Subject: [PATCH 02/14] Fixed double report message to admins
---
modules/commands/reports.lua | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/modules/commands/reports.lua b/modules/commands/reports.lua
index 00aff1b2..f5923066 100644
--- a/modules/commands/reports.lua
+++ b/modules/commands/reports.lua
@@ -9,6 +9,15 @@ local Reports = require 'modules.control.reports' --- @dep modules.control.repor
local format_chat_player_name = _C.format_chat_player_name--- @dep expcore.common
require 'config.expcore.command_general_parse'
+--- Print a message to all players who match the value of admin
+local function print_to_players(admin, message)
+ for _, player in ipairs(game.connected_players) do
+ if player.admin == admin then
+ player.print(message)
+ end
+ end
+end
+
--- Reports a player and notifies moderators
-- @command report
-- @tparam LuaPlayer player the player to report, some players are immune
@@ -30,8 +39,8 @@ end)
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
if Reports.report_player(action_player, player.name, reason) then
- game.print{'expcom-report.non-admin', action_player_name_color, reason}
- Roles.print_to_roles_higher('Trainee', {'expcom-report.admin', action_player_name_color, by_player_name_color, reason})
+ print_to_players(false, {'expcom-report.non-admin', action_player_name_color, reason})
+ print_to_players(true, {'expcom-report.admin', action_player_name_color, by_player_name_color, reason})
else
return Commands.error{'expcom-report.already-reported'}
end
From 3c718fa081771ef590e3877176d80d513ded2a40 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Mon, 5 Apr 2021 22:50:16 +0100
Subject: [PATCH 03/14] Fixed empty reasons
---
modules/control/reports.lua | 2 +-
modules/gui/player-list.lua | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/modules/control/reports.lua b/modules/control/reports.lua
index ea2a710f..354c8235 100644
--- a/modules/control/reports.lua
+++ b/modules/control/reports.lua
@@ -132,7 +132,7 @@ function Reports.report_player(player, by_player_name, reason)
if not player then return end
local player_name = player.name
- reason = reason or 'Non given.'
+ if reason == nil or not reason:find("/S") then reason = 'Non given' end
local reports = user_reports[player_name]
if not reports then
diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua
index f0923073..8d273a5f 100644
--- a/modules/gui/player-list.lua
+++ b/modules/gui/player-list.lua
@@ -72,9 +72,10 @@ Gui.element{
}
:style(Gui.sprite_style(30, -1, { left_margin = -2, right_margin = -1 }))
:on_click(function(player, element)
- local reason = element.parent.entry.text or 'Non Given'
+ local reason = element.parent.entry.text
local action_name = SelectedAction:get(player)
local reason_callback = config.buttons[action_name].reason_callback
+ if reason == nil or not reason:find("/S") then reason = 'no reason given' end
reason_callback(player, reason)
SelectedPlayer:remove(player)
SelectedAction:remove(player)
From 93a446747bed210aa83cbf0a203cd98a3a2211b2 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Mon, 5 Apr 2021 22:55:25 +0100
Subject: [PATCH 04/14] Fixed self reporting
---
config/gui/player_list_actions.lua | 1 +
locale/en/commands.cfg | 1 +
modules/commands/reports.lua | 2 ++
3 files changed, 4 insertions(+)
diff --git a/config/gui/player_list_actions.lua b/config/gui/player_list_actions.lua
index 1464a1d3..411d2395 100644
--- a/config/gui/player_list_actions.lua
+++ b/config/gui/player_list_actions.lua
@@ -173,6 +173,7 @@ return {
},
['command/report'] = {
auth=function(player,selected_player)
+ if player == selected_player then return false end
if not Roles.player_allowed(player,'command/give-warning') then
return not Roles.player_has_flag(selected_player,'report-immune')
end
diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg
index dea7b935..1a053c7e 100644
--- a/locale/en/commands.cfg
+++ b/locale/en/commands.cfg
@@ -29,6 +29,7 @@ not-jailed=__1__ is not currently in jail.
[expcom-report]
player-immune=This player can not be reported.
+self-report=You can not report your self.
non-admin=__1__ was reported for __2__.
admin=__1__ was reported by __2__ for __3__.
already-reported=You can only report a player once, you can ask a moderator to clear this report.
diff --git a/modules/commands/reports.lua b/modules/commands/reports.lua
index f5923066..6609189e 100644
--- a/modules/commands/reports.lua
+++ b/modules/commands/reports.lua
@@ -28,6 +28,8 @@ Commands.new_command('report', 'Reports a player and notifies moderators')
if not input then return end
if Roles.player_has_flag(input, 'report-immune') then
return reject{'expcom-report.player-immune'}
+ elseif player == input then
+ return reject{'expcom-report.self-report'}
else
return input
end
From 91bcda6d487b9827381480723bdf329edcfe1d6c Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Tue, 6 Apr 2021 01:22:31 +0100
Subject: [PATCH 05/14] Added afk kick
---
config/_file_loader.lua | 1 +
config/afk_kick.lua | 9 +++++
modules/addons/afk-kick.lua | 66 +++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+)
create mode 100644 config/afk_kick.lua
create mode 100644 modules/addons/afk-kick.lua
diff --git a/config/_file_loader.lua b/config/_file_loader.lua
index 16a135af..ab25db07 100644
--- a/config/_file_loader.lua
+++ b/config/_file_loader.lua
@@ -43,6 +43,7 @@ return {
'modules.addons.discord-alerts',
'modules.addons.chat-reply',
'modules.addons.tree-decon',
+ 'modules.addons.afk-kick',
--- Data
'modules.data.statistics',
diff --git a/config/afk_kick.lua b/config/afk_kick.lua
new file mode 100644
index 00000000..800b9730
--- /dev/null
+++ b/config/afk_kick.lua
@@ -0,0 +1,9 @@
+return {
+ admin_as_active = true, --- @setting admin_as_active When true admins will be treated as active regardless of afk time
+ trust_as_active = true, --- @setting trust_as_active When true trusted players (by playtime) will be treated as active regardless of afk time
+ active_role = 'Veteran', --- @setting active_role When not nil a player with this role will be treated as active regardless of afk time
+ afk_time = 3600*10, --- @setting afk_time The time in ticks that must pass for a player to be considered afk
+ kick_time = 3600*30, --- @setting kick_time The time in ticks that must pass without any active players for all players to be kicked
+ trust_time = 3600*60*10, --- @setting trust_time The time in ticks that a player must be online for to count as trusted
+ update_time = 3600*30, --- @setting update_time How often in ticks the script check for active players
+}
\ No newline at end of file
diff --git a/modules/addons/afk-kick.lua b/modules/addons/afk-kick.lua
new file mode 100644
index 00000000..578e57b8
--- /dev/null
+++ b/modules/addons/afk-kick.lua
@@ -0,0 +1,66 @@
+--- Kicks players when all players on the server are afk
+-- @addon afk-kick
+
+local Event = require 'utils.event' --- @dep utils.event
+local Global = require 'utils.global' --- @dep utils.global
+local config = require 'config.afk_kick' --- @dep config.afk_kick
+local Async = require 'expcore.async' --- @dep expcore.async
+
+--- Optional roles require
+local Roles
+if config.active_role then
+ Roles = require 'expcore.roles'
+end
+
+--- Globals
+local primitives = { last_active = 0 }
+Global.register(primitives, function(tbl)
+ primitives = tbl
+end)
+
+--- Kicks an afk player, used to give to for gui to show
+local kick_player =
+Async.register(function(player)
+ if game.tick - primitives.last_active < config.kick_time then return end -- Safety Catch
+ game.kick_player(player, 'Afk while no active players on the server')
+end)
+
+--- Check for an active player every 5 minutes
+Event.on_nth_tick(config.update_time, function()
+ -- Check for active players
+ for _, player in ipairs(game.connected_players) do
+ if player.afk_time < config.afk_time
+ or config.admin_as_active and config.player.admin
+ or config.trust_as_active and player.online_time > config.trust_time
+ or config.active_role and Roles.player_has_role(player, config.active_role) then
+ -- Active player was found
+ primitives.last_active = game.tick
+ return
+ end
+ end
+
+ -- No active player was found, check if players should be kicked
+ if game.tick - primitives.last_active < config.kick_time then return end
+
+ -- Kick time exceeded, kick all players
+ for _, player in ipairs(game.connected_players) do
+ -- Add a frame to say why the player was kicked
+ local res = player.display_resolution
+ local uis = player.display_scale
+ player.gui.screen.add{
+ type = 'frame',
+ name = 'afk-kick',
+ caption = 'All players were kicked because everyone was afk.',
+ }.location = { x=res.width*(0.5 - 0.11*uis), y=res.height*(0.5 - 0.14*uis) }
+
+ -- Kick the player, some delay needed because network delay
+ Async.wait(10, kick_player, player)
+ end
+end)
+
+--- Remove the screen gui if it is present
+Event.add(defines.events.on_player_joined_game, function(event)
+ local player = game.get_player(event.player_index)
+ local frame = player.gui.screen["afk-kick"]
+ if frame and frame.valid then frame.destroy() end
+end)
\ No newline at end of file
From 4e9e2747fb5eb61e152aa178f786f1eed445e2b4 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Tue, 6 Apr 2021 22:58:10 +0100
Subject: [PATCH 06/14] Made requested changes
---
config/afk_kick.lua | 2 +-
locale/en/addons.cfg | 5 ++++-
modules/addons/afk-kick.lua | 8 ++++----
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/config/afk_kick.lua b/config/afk_kick.lua
index 800b9730..d0be3e1b 100644
--- a/config/afk_kick.lua
+++ b/config/afk_kick.lua
@@ -5,5 +5,5 @@ return {
afk_time = 3600*10, --- @setting afk_time The time in ticks that must pass for a player to be considered afk
kick_time = 3600*30, --- @setting kick_time The time in ticks that must pass without any active players for all players to be kicked
trust_time = 3600*60*10, --- @setting trust_time The time in ticks that a player must be online for to count as trusted
- update_time = 3600*30, --- @setting update_time How often in ticks the script check for active players
+ update_time = 3600*30, --- @setting update_time How often in ticks the script checks for active players
}
\ No newline at end of file
diff --git a/locale/en/addons.cfg b/locale/en/addons.cfg
index 95defd53..af26b91a 100644
--- a/locale/en/addons.cfg
+++ b/locale/en/addons.cfg
@@ -75,4 +75,7 @@ get-mead-1= Filling the drinking horn
get-mead-2= Skål!
get-beer-1= 🍺 Pouring A Glass 🍺
get-beer-2= 🍻 Chears Mate 🍻
-verify=Please return to our discord and type r!verify __1__
\ No newline at end of file
+verify=Please return to our discord and type r!verify __1__
+
+[afk-kick]
+message=All players were kicked because everyone was AFK.
\ No newline at end of file
diff --git a/modules/addons/afk-kick.lua b/modules/addons/afk-kick.lua
index 578e57b8..9bea3b05 100644
--- a/modules/addons/afk-kick.lua
+++ b/modules/addons/afk-kick.lua
@@ -18,14 +18,14 @@ Global.register(primitives, function(tbl)
primitives = tbl
end)
---- Kicks an afk player, used to give to for gui to show
+--- Kicks an afk player, used to add a delay so the gui has time to appear
local kick_player =
Async.register(function(player)
if game.tick - primitives.last_active < config.kick_time then return end -- Safety Catch
- game.kick_player(player, 'Afk while no active players on the server')
+ game.kick_player(player, 'AFK while no active players on the server')
end)
---- Check for an active player every 5 minutes
+--- Check for an active player every update_time number of ticks
Event.on_nth_tick(config.update_time, function()
-- Check for active players
for _, player in ipairs(game.connected_players) do
@@ -50,7 +50,7 @@ Event.on_nth_tick(config.update_time, function()
player.gui.screen.add{
type = 'frame',
name = 'afk-kick',
- caption = 'All players were kicked because everyone was afk.',
+ caption = {'afk-kick.message'},
}.location = { x=res.width*(0.5 - 0.11*uis), y=res.height*(0.5 - 0.14*uis) }
-- Kick the player, some delay needed because network delay
From 51c5a5b1f83365b780dd208433965f036b864135 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 7 Apr 2021 01:01:41 +0100
Subject: [PATCH 07/14] Added search commands
---
config/_file_loader.lua | 1 +
config/expcore/roles.lua | 4 +
locale/en/commands.cfg | 8 +-
modules/commands/search.lua | 167 ++++++++++++++++++++++++++++++++++++
4 files changed, 179 insertions(+), 1 deletion(-)
create mode 100644 modules/commands/search.lua
diff --git a/config/_file_loader.lua b/config/_file_loader.lua
index 16a135af..caa311da 100644
--- a/config/_file_loader.lua
+++ b/config/_file_loader.lua
@@ -29,6 +29,7 @@ return {
'modules.commands.home',
'modules.commands.connect',
'modules.commands.last-location',
+ 'modules.commands.search',
--- Addons
'modules.addons.chat-popups',
diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua
index 9b826202..4125677c 100644
--- a/config/expcore/roles.lua
+++ b/config/expcore/roles.lua
@@ -102,6 +102,10 @@ Roles.new_role('Trainee','TrMod')
'command/unjail',
'command/kick',
'command/ban',
+ 'command/search',
+ 'command/search-amount',
+ 'command/search-recent',
+ 'command/search-online',
}
--- Trusted Roles
diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg
index dea7b935..cb5ab590 100644
--- a/locale/en/commands.cfg
+++ b/locale/en/commands.cfg
@@ -82,4 +82,10 @@ offline=You cannot connect as the server is currently offline: __1__
none-matching=No servers were found with that name, if you used an address please append true to the end of your command.
[expcom-lastlocation]
-response=Last location of __1__ was [gps=__2__,__3__]
\ No newline at end of file
+response=Last location of __1__ was [gps=__2__,__3__]
+
+[expcom-inv-search]
+reject-item=No item was found with internal name __1__; try using rich text selection.
+results-heading=Players found with [item=__1__]:
+results-item=__1__) __2__ has __3__ items. (__4__)
+results-none=No players have [item=__1__]
\ No newline at end of file
diff --git a/modules/commands/search.lua b/modules/commands/search.lua
new file mode 100644
index 00000000..52143bdd
--- /dev/null
+++ b/modules/commands/search.lua
@@ -0,0 +1,167 @@
+--[[-- Commands Module - Inventory Search
+ - Adds commands that will search all players inventories for an item
+ @commands InventorySearch
+]]
+
+local Commands = require 'expcore.commands' --- @dep expcore.commands
+local format_number = require('util').format_number --- @dep util
+local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
+local format_time = _C.format_time
+require 'config.expcore.command_general_parse'
+
+--- Input parse for items by name
+local function item_parse(input, _, reject)
+ if input == nil then return end
+ local lower_input = input:lower():gsub(' ', '-')
+
+ -- Simple Case - internal name is given
+ local item = game.item_prototypes[lower_input]
+ if item then return item end
+
+ -- Second Case - rich text is given
+ local item_name = input:match('%[item=([0-9a-z-]+)%]')
+ item = game.item_prototypes[item_name]
+ if item then return item end
+
+ -- No item found, we do not attempt to search all prototypes as this will be expensive
+ return reject{'expcom-inv-search.reject-item', lower_input}
+end
+
+--- Search all players for this item
+local function search_players(players, item)
+ local head = 1
+ local found = {}
+
+ -- Check the item count of all players
+ for _, player in pairs(players) do
+ local item_count = player.get_item_count(item.name)
+ if item_count > 0 then
+ -- Add the player to the array as they have the item
+ found[head] = { player=player, count=item_count, online_time=player.online_time }
+ head = head + 1
+ end
+ end
+
+ return found
+end
+
+--- Custom sort function which only retains 5 greatest values
+local function sort_players(players, func)
+ local sorted = {}
+ local values = {}
+ local threshold = nil
+
+ -- Loop over all provided players
+ for index, player in ipairs(players) do
+ local value = func(player)
+ -- Check if the item will make the top 10 elements
+ if value > threshold or index <= 5 then
+ local inserted = false
+ values[player] = value
+ -- Find where in the top 10 to insert the element
+ for next_index, next_player in ipairs(sorted) do
+ if value > values[next_player] then
+ table.insert(sorted, next_index, player)
+ inserted = true
+ break
+ end
+ end
+ -- Insert the element, this can only be called when index <= 5
+ if not inserted then
+ sorted[#sorted+1] = player
+ end
+ -- Update the threshold
+ if sorted[6] then
+ threshold = values[sorted[5]]
+ values[sorted[6]] = nil
+ sorted[6] = nil
+ else
+ threshold = values[sorted[#sorted]]
+ end
+ end
+ end
+
+ return sorted
+end
+
+--- Display to the player the top players which were found
+local function display_players(player, players, item)
+ player.print{'expcom-inv-search.results-heading', item.name}
+ for index, data in ipairs(players) do
+ local player_name_color = format_chat_player_name(data.player)
+ local amount = format_number(data.count)
+ local time = format_time(data.online_time)
+ player.print{'expcom-inv-search.results-item', index, player_name_color, amount, time}
+ end
+end
+
+--- Return the amount of an item a player has
+local function amount_sort(data)
+ return data.count
+end
+
+--- Get a list of players sorted by the quantity of an item in their inventory
+-- @command search-amount
+-- @tparam LuaItemPrototype item The item to search for in players inventories
+Commands.new_command('search-amount', 'Display players sorted by the quantity of an item held')
+:add_alias('ia')
+:add_param('item', false, item_parse)
+:enable_auto_concat()
+:register(function(player, item)
+ local players = search_players(game.players, item)
+ if #players == 0 then return {'expcom-inv-search.results-none', item.name} end
+ local top_players = sort_players(players, amount_sort)
+ display_players(player, top_players, item)
+end)
+
+--- Return the index of the player, higher means they joined more recently
+local function recent_sort(data)
+ return data.player.index
+end
+
+--- Get a list of players who have the given item, sorted by how recently they joined
+-- @command search-recent
+-- @tparam LuaItemPrototype item The item to search for in players inventories
+Commands.new_command('search-recent', 'Display players who hold an item sorted by join time')
+:add_alias('ir')
+:add_param('item', false, item_parse)
+:enable_auto_concat()
+:register(function(player, item)
+ local players = search_players(game.players, item)
+ if #players == 0 then return {'expcom-inv-search.results-none', item.name} end
+ local top_players = sort_players(players, recent_sort)
+ display_players(player, top_players, item)
+end)
+
+--- Return the index of the player, higher means they joined more recently
+local function combined_sort(data)
+ return data.count/data.online_time
+end
+
+--- Get a list of players sorted by quantity held and play time
+-- @command search
+-- @tparam LuaItemPrototype item The item to search for in players inventories
+Commands.new_command('search', 'Display players sorted by the quantity of an item held and playtime')
+:add_alias('i')
+:add_param('item', false, item_parse)
+:enable_auto_concat()
+:register(function(player, item)
+ local players = search_players(game.players, item)
+ if #players == 0 then return {'expcom-inv-search.results-none', item.name} end
+ local top_players = sort_players(players, combined_sort)
+ display_players(player, top_players, item)
+end)
+
+--- Get a list of online players sorted by quantity held and play time
+-- @command search-online
+-- @tparam LuaItemPrototype item The item to search for in players inventories
+Commands.new_command('search-online', 'Display online players sorted by the quantity of an item held and playtime')
+:add_alias('io')
+:add_param('item', false, item_parse)
+:enable_auto_concat()
+:register(function(player, item)
+ local players = search_players(game.connected_players, item)
+ if #players == 0 then return {'expcom-inv-search.results-none', item.name} end
+ local top_players = sort_players(players, combined_sort)
+ display_players(player, top_players, item)
+end)
\ No newline at end of file
From fa38e3438030ec3864a8c22a8f425c19ed91d89b Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 7 Apr 2021 01:59:56 +0100
Subject: [PATCH 08/14] Fixed inline bug
---
modules/addons/discord-alerts.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/addons/discord-alerts.lua b/modules/addons/discord-alerts.lua
index fbeabf8a..a5309b12 100644
--- a/modules/addons/discord-alerts.lua
+++ b/modules/addons/discord-alerts.lua
@@ -59,7 +59,7 @@ local function emit_event(args)
}
local new_value, inline = value:gsub('', '', 1)
- if inline then
+ if inline > 0 then
field.value = new_value
field.inline = true
end
From fd70ea3bd050ae9fb101ba740265e5fa2c6065f5 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 7 Apr 2021 02:02:49 +0100
Subject: [PATCH 09/14] Added report and warning count
---
modules/addons/discord-alerts.lua | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/modules/addons/discord-alerts.lua b/modules/addons/discord-alerts.lua
index a5309b12..d1c4646c 100644
--- a/modules/addons/discord-alerts.lua
+++ b/modules/addons/discord-alerts.lua
@@ -87,6 +87,7 @@ if config.player_reports then
color=Colors.yellow,
['Player']=''..player_name,
['By']=''..by_player_name,
+ ['Report Count']=''..Reports.count_reports(player_name),
['Reason']=event.reason
}
end)
@@ -99,7 +100,7 @@ if config.player_reports then
color=Colors.green,
['Player']=''..player_name,
['By']=''..event.removed_by_name,
- ['Amount']=''..event.batch_count
+ ['Report Count']=''..event.batch_count
}
end)
end
@@ -109,12 +110,14 @@ if config.player_warnings then
local Warnings = require 'modules.control.warnings' --- @dep modules.control.warnings
Event.add(Warnings.events.on_warning_added, function(event)
local player_name, by_player_name = get_player_name(event)
+ local player = game.get_player(player_name)
emit_event{
title='Warning',
description='A player has been given a warning',
color=Colors.yellow,
['Player']=''..player_name,
['By']=''..by_player_name,
+ ['Warning Count']=''..Warnings.count_warnings(player),
['Reason']=event.reason
}
end)
@@ -127,7 +130,7 @@ if config.player_warnings then
color=Colors.green,
['Player']=''..player_name,
['By']=''..event.removed_by_name,
- ['Amount']=''..event.batch_count
+ ['Warning Count']=''..event.batch_count
}
end)
end
From b86efbb9435f50346e3f4ae07c12e51e17325492 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Wed, 7 Apr 2021 18:07:04 +0100
Subject: [PATCH 10/14] Made requested changes
---
modules/commands/search.lua | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/modules/commands/search.lua b/modules/commands/search.lua
index 52143bdd..62d1ab33 100644
--- a/modules/commands/search.lua
+++ b/modules/commands/search.lua
@@ -54,11 +54,11 @@ local function sort_players(players, func)
-- Loop over all provided players
for index, player in ipairs(players) do
local value = func(player)
- -- Check if the item will make the top 10 elements
+ -- Check if the item will make the top 5 elements
if value > threshold or index <= 5 then
local inserted = false
values[player] = value
- -- Find where in the top 10 to insert the element
+ -- Find where in the top 5 to insert the element
for next_index, next_player in ipairs(sorted) do
if value > values[next_player] then
table.insert(sorted, next_index, player)
@@ -133,7 +133,7 @@ Commands.new_command('search-recent', 'Display players who hold an item sorted b
display_players(player, top_players, item)
end)
---- Return the index of the player, higher means they joined more recently
+--- Return the the amount of an item a player has divided by their playtime
local function combined_sort(data)
return data.count/data.online_time
end
From 70664ffd0c88b37e96abfa2ebc122119ac6c24ec Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Thu, 8 Apr 2021 18:08:41 +0100
Subject: [PATCH 11/14] Made requested changes
---
locale/en/addons.cfg | 2 +-
locale/en/commands.cfg | 2 +-
modules/addons/report-jail.lua | 4 ++--
modules/control/reports.lua | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/locale/en/addons.cfg b/locale/en/addons.cfg
index 9acd4abc..65510fae 100644
--- a/locale/en/addons.cfg
+++ b/locale/en/addons.cfg
@@ -78,4 +78,4 @@ get-beer-2= 🍻 Chears Mate 🍻
verify=Please return to our discord and type r!verify __1__
[report-jail]
-jail=__1__ was jailed because they have been reported too many times.
\ No newline at end of file
+jail=__1__ was jailed because they were reported too many times.
\ No newline at end of file
diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg
index 1a053c7e..3aea89ed 100644
--- a/locale/en/commands.cfg
+++ b/locale/en/commands.cfg
@@ -29,7 +29,7 @@ not-jailed=__1__ is not currently in jail.
[expcom-report]
player-immune=This player can not be reported.
-self-report=You can not report your self.
+self-report=You cannot report yourself.
non-admin=__1__ was reported for __2__.
admin=__1__ was reported by __2__ for __3__.
already-reported=You can only report a player once, you can ask a moderator to clear this report.
diff --git a/modules/addons/report-jail.lua b/modules/addons/report-jail.lua
index b98c3ce0..f9211993 100644
--- a/modules/addons/report-jail.lua
+++ b/modules/addons/report-jail.lua
@@ -1,4 +1,4 @@
---- When a player is reported by players with a greater combined delta playtime, the player is automatically jailed
+--- When a player is reported, the player is automatically jailed if the combined playtime of the reporters exceeds the reported player
-- @addon report-jail
local Event = require 'utils.event' ---@dep utils.event
@@ -6,7 +6,7 @@ local Jail = require 'modules.control.jail' ---@dep modules.control.jail
local Reports = require 'modules.control.reports' --- @dep modules.control.reports
local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
---- Returns the playtime of the reporter, used to sum the playtime of all reporters
+--- Returns the playtime of the reporter. Used when calculating the total playtime of all reporters
local function reporter_playtime(_, by_player_name, _)
local player = game.get_player(by_player_name)
if player == nil then return 0 end
diff --git a/modules/control/reports.lua b/modules/control/reports.lua
index 354c8235..62d3bea7 100644
--- a/modules/control/reports.lua
+++ b/modules/control/reports.lua
@@ -132,7 +132,7 @@ function Reports.report_player(player, by_player_name, reason)
if not player then return end
local player_name = player.name
- if reason == nil or not reason:find("/S") then reason = 'Non given' end
+ if reason == nil or not reason:find("/S") then reason = 'No reason given' end
local reports = user_reports[player_name]
if not reports then
From 5c0e3b65e40484e4b1a8e16783ca3733b1e0bce5 Mon Sep 17 00:00:00 2001
From: Cooldude2606
Date: Sat, 24 Apr 2021 20:23:46 +0000
Subject: [PATCH 12/14] Automatic Doc Update
---
docs/addons/Advanced-Start.html | 3 +-
docs/addons/Chat-Popups.html | 3 +-
docs/addons/Chat-Reply.html | 3 +-
docs/addons/Compilatron.html | 3 +-
docs/addons/Damage-Popups.html | 3 +-
docs/addons/Death-Logger.html | 3 +-
docs/addons/Discord-Alerts.html | 3 +-
docs/addons/Inventory-Clear.html | 3 +-
docs/addons/Pollution-Grading.html | 3 +-
docs/addons/Scorched-Earth.html | 3 +-
docs/addons/Spawn-Area.html | 3 +-
docs/addons/Tree-Decon.html | 3 +-
docs/addons/report-jail.html | 404 ++++++++++++++++++
docs/commands/Admin-Chat.html | 3 +-
docs/commands/Cheat-Mode.html | 3 +-
docs/commands/Clear-Inventory.html | 3 +-
docs/commands/Connect.html | 3 +-
docs/commands/Debug.html | 3 +-
docs/commands/Find.html | 3 +-
docs/commands/Help.html | 3 +-
docs/commands/Home.html | 3 +-
docs/commands/Interface.html | 3 +-
docs/commands/Jail.html | 3 +-
docs/commands/Kill.html | 3 +-
docs/commands/LastLocation.html | 3 +-
docs/commands/Me.html | 3 +-
docs/commands/Rainbow.html | 3 +-
docs/commands/Repair.html | 3 +-
docs/commands/Reports.html | 3 +-
docs/commands/Roles.html | 3 +-
docs/commands/Spawn.html | 3 +-
docs/commands/Teleport.html | 3 +-
docs/commands/Warnings.html | 3 +-
docs/configs/Advanced-Start.html | 3 +-
docs/configs/Autofill.html | 3 +-
docs/configs/Bonuses.html | 3 +-
docs/configs/Chat-Reply.html | 3 +-
docs/configs/Commands-Auth-Admin.html | 3 +-
docs/configs/Commands-Auth-Roles.html | 3 +-
.../Commands-Auth-Runtime-Disable.html | 3 +-
docs/configs/Commands-Color-Parse.html | 3 +-
docs/configs/Commands-Parse-Roles.html | 3 +-
docs/configs/Commands-Parse.html | 3 +-
docs/configs/Compilatron.html | 3 +-
docs/configs/Death-Logger.html | 3 +-
docs/configs/Discord-Alerts.html | 3 +-
docs/configs/File-Loader.html | 3 +-
docs/configs/Permission-Groups.html | 3 +-
docs/configs/Player-List.html | 3 +-
docs/configs/Pollution-Grading.html | 3 +-
docs/configs/Popup-Messages.html | 3 +-
docs/configs/Preset-Player-Colours.html | 3 +-
docs/configs/Preset-Player-Quickbar.html | 3 +-
docs/configs/Repair.html | 3 +-
docs/configs/Rockets.html | 3 +-
docs/configs/Roles.html | 3 +-
docs/configs/Science.html | 3 +-
docs/configs/Scorched-Earth.html | 3 +-
docs/configs/Spawn-Area.html | 3 +-
docs/configs/Statistics.html | 3 +-
docs/configs/Tasks.html | 3 +-
docs/configs/Warnings.html | 3 +-
docs/configs/Warps.html | 3 +-
docs/configs/inventory_clear.html | 3 +-
docs/control/Jail.html | 3 +-
docs/control/Production.html | 3 +-
docs/control/Reports.html | 3 +-
docs/control/Rockets.html | 3 +-
docs/control/Tasks.html | 3 +-
docs/control/Warnings.html | 3 +-
docs/control/Warps.html | 3 +-
docs/core/Async.html | 3 +-
docs/core/Commands.html | 3 +-
docs/core/Common.html | 3 +-
docs/core/Datastore.html | 3 +-
docs/core/External.html | 3 +-
docs/core/Groups.html | 3 +-
docs/core/Gui.html | 3 +-
docs/core/PlayerData.html | 3 +-
docs/core/Roles.html | 3 +-
docs/data/Alt-View.html | 3 +-
docs/data/Bonus.html | 3 +-
docs/data/Greetings.html | 3 +-
docs/data/Player-Colours.html | 3 +-
docs/data/Quickbar.html | 3 +-
docs/data/Tag.html | 3 +-
docs/guis/Autofill.html | 3 +-
docs/guis/Player-List.html | 3 +-
docs/guis/Readme.html | 3 +-
docs/guis/Rocket-Info.html | 3 +-
docs/guis/Science-Info.html | 3 +-
docs/guis/Task-List.html | 3 +-
docs/guis/Warps-List.html | 3 +-
docs/guis/server-ups.html | 3 +-
docs/index.html | 6 +-
docs/modules/control.html | 3 +-
.../modules.addons.station-auto-name.html | 3 +-
docs/modules/overrides.debug.html | 3 +-
docs/modules/overrides.math.html | 3 +-
docs/modules/overrides.table.html | 3 +-
docs/modules/utils.event.html | 3 +-
docs/modules/utils.event_core.html | 3 +-
docs/modules/utils.task.html | 3 +-
docs/topics/LICENSE.html | 3 +-
docs/topics/README.md.html | 3 +-
105 files changed, 615 insertions(+), 104 deletions(-)
create mode 100644 docs/addons/report-jail.html
diff --git a/docs/addons/Advanced-Start.html b/docs/addons/Advanced-Start.html
index b62dd959..f7f66160 100644
--- a/docs/addons/Advanced-Start.html
+++ b/docs/addons/Advanced-Start.html
@@ -58,6 +58,7 @@
@@ -2432,7 +2433,7 @@ nb: use error(error_message) within your callback to trigger do not trigger dire
generated by LDoc
diff --git a/docs/core/Common.html b/docs/core/Common.html
index f9323565..f659cf9d 100644
--- a/docs/core/Common.html
+++ b/docs/core/Common.html
@@ -92,6 +92,7 @@
@@ -3395,7 +3396,7 @@ nb: this is one way, failing false after already gaining the role will not revok
generated by LDoc
diff --git a/docs/data/Alt-View.html b/docs/data/Alt-View.html
index ee809c01..c231c94e 100644
--- a/docs/data/Alt-View.html
+++ b/docs/data/Alt-View.html
@@ -101,6 +101,7 @@
@@ -2433,7 +2434,7 @@ nb: use error(error_message) within your callback to trigger do not trigger dire
generated by LDoc
diff --git a/docs/core/Common.html b/docs/core/Common.html
index f659cf9d..c6034145 100644
--- a/docs/core/Common.html
+++ b/docs/core/Common.html
@@ -84,6 +84,7 @@
@@ -3396,7 +3397,7 @@ nb: this is one way, failing false after already gaining the role will not revok
generated by LDoc
diff --git a/docs/data/Alt-View.html b/docs/data/Alt-View.html
index c231c94e..7db3f458 100644
--- a/docs/data/Alt-View.html
+++ b/docs/data/Alt-View.html
@@ -93,6 +93,7 @@
@@ -2434,7 +2435,7 @@ nb: use error(error_message) within your callback to trigger do not trigger dire
generated by LDoc
diff --git a/docs/core/Common.html b/docs/core/Common.html
index c6034145..9d8479d7 100644
--- a/docs/core/Common.html
+++ b/docs/core/Common.html
@@ -149,6 +149,7 @@
@@ -3397,7 +3398,7 @@ nb: this is one way, failing false after already gaining the role will not revok
generated by LDoc
diff --git a/docs/data/Alt-View.html b/docs/data/Alt-View.html
index 7db3f458..1c48b0db 100644
--- a/docs/data/Alt-View.html
+++ b/docs/data/Alt-View.html
@@ -145,6 +145,7 @@
@@ -514,7 +515,7 @@
generated by LDoc
diff --git a/docs/index.html b/docs/index.html
index e58e2d4b..50153a2b 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -350,6 +350,11 @@
- Adds a commands that allow interaction with the role system