From 294766714a9a46d0a3ade300aa65bf02785486fb Mon Sep 17 00:00:00 2001 From: badgamernl Date: Sat, 7 Nov 2020 01:10:11 +0100 Subject: [PATCH] Removed Temp ban related stuff --- config/discord_alerts.lua | 1 - config/expcore/roles.lua | 2 - config/gui/player_list_actions.lua | 24 -------- locale/en/commands.cfg | 4 -- locale/en/gui.cfg | 1 - modules/addons/discord-alerts.lua | 26 -------- modules/commands/jail.lua | 37 +----------- modules/control/jail.lua | 96 +----------------------------- 8 files changed, 4 insertions(+), 187 deletions(-) diff --git a/config/discord_alerts.lua b/config/discord_alerts.lua index dc9c48c4..1890aa4b 100644 --- a/config/discord_alerts.lua +++ b/config/discord_alerts.lua @@ -9,7 +9,6 @@ return { player_kicks=true, player_promotes=false, player_jail=true, - player_temp_ban=true, ['config']=true, ['purge']=true, ['c']=true, diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua index e28ac848..baad6f93 100644 --- a/config/expcore/roles.lua +++ b/config/expcore/roles.lua @@ -71,7 +71,6 @@ Roles.new_role('Moderator','Mod') 'command/go-to-spawn/always', 'command/clear-reports', 'command/clear-warnings', - 'command/clear-temp-ban', 'command/clear-inventory', 'command/bonus', 'command/home', @@ -96,7 +95,6 @@ Roles.new_role('Trainee','TrMod') 'command/teleport', 'command/bring', 'command/goto', - 'command/temp-ban', 'command/give-warning', 'command/get-warnings', 'command/get-reports', diff --git a/config/gui/player_list_actions.lua b/config/gui/player_list_actions.lua index 2d956e94..508dacd3 100644 --- a/config/gui/player_list_actions.lua +++ b/config/gui/player_list_actions.lua @@ -150,25 +150,6 @@ local function jail_player_callback(player,reason) Jail.jail_player(selected_player_name,player.name,reason) end ---- Temp bans the action player, requires a reason --- @element temp_ban_player -local temp_ban_player = new_button('utility/warning_white',{'player-list.temp-ban-player'}) -:on_click(function(player) - local selected_player_name, selected_player_color = get_action_player_name(player) - if Jail.is_jailed(selected_player_name) then - player.print({'expcom-jail.already-banned', selected_player_color},Colors.orange_red) - else - SelectedAction:set(player, 'command/temp-ban') - end -end) - -local function temp_ban_player_callback(player,reason) - local selected_player, selected_player_color = get_action_player_name(player) - local by_player_name_color = format_chat_player_name(player) - game.print{'expcom-jail.temp-ban', selected_player_color,by_player_name_color,reason} - Jail.temp_ban_player(selected_player,player.name,reason) -end - --- Kicks the action player, requires a reason -- @element kick_player local kick_player = new_button('utility/warning_icon',{'player-list.kick-player'}) @@ -232,11 +213,6 @@ return { reason_callback=jail_player_callback, jail_player }, - ['command/temp-ban'] = { - auth=auth_lower_role, - reason_callback=temp_ban_player_callback, - temp_ban_player - }, ['command/kick'] = { auth=auth_lower_role, reason_callback=kick_player_callback, diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index 6c9fb44f..57f7754c 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -26,10 +26,6 @@ give=__1__ was jailed by __2__. Reason: __3__ remove=__1__ was unjailed by __2__. already-jailed=__1__ is already in jail. not-jailed=__1__ is not currently in jail. -temp-ban=__1__ was temp banned until next reset by __2__. Reason: __3__ -temp-ban-clear=__1__ was cleared from temp banned by __2__. -not-temp-banned=__1__ is not currently temp banned. -already-banned=__1__ is already banned. [expcom-report] player-immune=This player can not be reported. diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg index e4fa8611..09583413 100644 --- a/locale/en/gui.cfg +++ b/locale/en/gui.cfg @@ -10,7 +10,6 @@ kill-player=Kill player report-player=Report player warn-player=Warn player jail-player=Jail player -temp-ban-player=Temp ban player kick-player=Kick player ban-player=Ban player afk-time=__1__% of total map time\nLast moved __2__ ago diff --git a/modules/addons/discord-alerts.lua b/modules/addons/discord-alerts.lua index 27b89ad9..fbeabf8a 100644 --- a/modules/addons/discord-alerts.lua +++ b/modules/addons/discord-alerts.lua @@ -158,32 +158,6 @@ if config.player_jail then end) end ---- When a player is tempbanned -if config.player_temp_ban then - local Jail = require 'modules.control.jail' - Event.add(Jail.events.on_player_temp_banned, function(event) - local player_name, by_player_name = get_player_name(event) - emit_event{ - title='Temp Ban', - description='A player has been temp banned', - color=Colors.red, - ['Player']=''..player_name, - ['By']=''..by_player_name, - ['Reason']=event.reason - } - end) - Event.add(Jail.events.on_player_untemp_banned, function(event) - local player_name, by_player_name = get_player_name(event) - emit_event{ - title='Temp Ban Removed', - description='A player has been untemp banned', - color=Colors.green, - ['Player']=''..player_name, - ['By']=''..by_player_name - } - end) -end - --- Ban and unban if config.player_bans then Event.add(defines.events.on_player_banned, function(event) diff --git a/modules/commands/jail.lua b/modules/commands/jail.lua index 98941616..a68553dc 100644 --- a/modules/commands/jail.lua +++ b/modules/commands/jail.lua @@ -1,5 +1,5 @@ --[[-- Commands Module - Jail - - Adds a commands that allow admins to jail, unjail, and temp ban players + - Adds a commands that allow admins to jail and unjail @commands Jail ]] @@ -45,38 +45,3 @@ Commands.new_command('unjail', 'Removes a player from jail.') return Commands.error{'expcom-jail.not-jailed', action_player_name_color} end end) - ---- Temp bans a player until the next reset; this requires a reason; this will clear the players inventory. --- @command temp-ban --- @tparam LuaPlayer player the player that will be temp banned --- @tparam string reason the reason that the player is being temp banned -Commands.new_command('temp-ban', 'Temp bans a player until the next reset; this requires a reason; this will clear the players inventory.') -:add_param('player', false, 'player-role') -:add_param('reason', false) -:enable_auto_concat() -:register(function(player, action_player, reason) - local action_player_name_color = format_chat_player_name(action_player) - local by_player_name_color = format_chat_player_name(player) - if Jail.temp_ban_player(action_player, player.name, reason) then - game.print{'expcom-jail.temp-ban', action_player_name_color, by_player_name_color, reason} - else - return Commands.error{'expcom-jail.already-banned', action_player_name_color} - end -end) - ---- Removes temp ban from a player; this will not restore their items. --- @command clear-temp-ban --- @tparam LuaPlayer player the player to revoke the temp ban from -Commands.new_command('clear-temp-ban', 'Removes temp ban from a player; this will not restore their items.') -:add_param('player', false, 'player-role') -:add_alias('untemp-ban', 'remove-temp-ban') -:enable_auto_concat() -:register(function(player, action_player) - local action_player_name_color = format_chat_player_name(action_player) - local by_player_name_color = format_chat_player_name(player) - if Jail.untemp_ban_player(action_player, player.name) then - game.print{'expcom-jail.temp-ban-clear', action_player_name_color, by_player_name_color} - else - return Commands.error{'expcom-jail.not-temp-banned', action_player_name_color} - end -end) diff --git a/modules/control/jail.lua b/modules/control/jail.lua index df46f9ce..6e2ca00f 100644 --- a/modules/control/jail.lua +++ b/modules/control/jail.lua @@ -1,5 +1,5 @@ --[[-- Control Module - Jail - - Adds a way to jail players and temp ban players. + - Adds a way to jail players. @control Jail @alias Jail @@ -14,16 +14,11 @@ -- This will give 'MrBiter' all his roles back and remove him from jail -- again as above the player name is only used in the event for user feedback Jail.unjail_player('MrBiter', 'Cooldude2606') - - -- Temp ban works the same as jail but will store the reason and move the players items to spawn - -- this is meant to be used as a more permiment jail but not as strong as a ban - Jail.temp_ban_player('MrBiter', 'Cooldude2606', 'Likes biters too much') ]] local Roles = require 'expcore.roles' --- @dep expcore.roles local Game = require 'utils.game' --- @dep utils.game local Global = require 'utils.global' --- @dep utils.global -local move_items = _C.move_items --- @dep expcore.common local valid_player = Game.get_player_from_any local assign_roles = Roles.assign_player @@ -33,7 +28,6 @@ local get_roles = Roles.get_player_roles local Jail = { old_roles = {}, - temp_bans = {}, events = { --- When a player is assigned to jail -- @event on_player_jailed @@ -46,37 +40,22 @@ local Jail = { -- @tparam number player_index the index of the player who was unjailed -- @tparam string by_player_name the name of the player who unjailed the other player on_player_unjailed=script.generate_event_name(), - --- When a player is temp banned - -- @event on_player_temp_banned - -- @tparam number player_index the index of the player who was temp banned - -- @tparam string by_player_name the name of the player who temp banned the other player - -- @tparam string reason the reason that the player was temp banned - on_player_temp_banned=script.generate_event_name(), - --- When a temp ban is removed from a player - -- @event on_player_untemp_banned - -- @tparam number player_index the index of the player who was untemp banned - -- @tparam string by_player_name the name of the player who untemp banned the other player - on_player_untemp_banned=script.generate_event_name() } } local old_roles = Jail.old_roles -local temp_bans = Jail.temp_bans Global.register({ - old_roles = old_roles, - temp_bans = temp_bans + old_roles = old_roles }, function(tbl) Jail.old_roles = tbl.old_roles - Jail.temp_bans = tbl.temp_bans old_roles = Jail.old_roles - temp_bans = Jail.temp_bans end) --- Used to emit the jail related events -- @tparam number event the name of the event that will be emited -- @tparam LuaPlayer player the player who is being acted on -- @tparam string by_player_name the player who is doing the action --- @tparam string reason the reason for the action (jail and tempban only) +-- @tparam string reason the reason for the action (jail) local function event_emit(event, player, by_player_name, reason) script.raise_event(event, { name=event, @@ -142,73 +121,4 @@ function Jail.unjail_player(player, by_player_name) return true end ---- Temp ban. --- Functions related to temp ban --- @section temp-ban-functions - ---- Checks if a player is temp banned --- @tparam LuaPlayer player the player to check if they are temp banned --- @treturn boolean whether the player is temp banned -function Jail.is_temp_banned(player) - player = valid_player(player) - if not player then return end - return temp_bans[player.name] ~= nil -end - ---- Temp bans a player by moving them to jail, clearing all other roles, storing the reason, and moving their items to spawn --- @tparam LuaPlayer player the player that will be temp banned --- @tparam string by_player_name the name of the player who is doing the temp ban --- @tparam[opt='Non given.'] string reason the reason that the player is being temp banned --- @treturn boolean whether the player was successfully temp banned -function Jail.temp_ban_player(player, by_player_name, reason) - player = valid_player(player) - if not player then return end - if not by_player_name then return end - - reason = reason or 'Non given.' - - if temp_bans[player.name] then return end - temp_bans[player.name] = {reason, by_player_name} - - if not has_role(player, 'Jail') then - local roles = get_roles(player) - old_roles[player.name] = roles - - assign_roles(player, 'Jail', by_player_name, nil, true) - unassign_roles(player, roles, by_player_name, nil, true) - end - - local inv = player.get_main_inventory() - move_items(inv.get_contents()) - inv.clear() - - event_emit(Jail.events.on_player_temp_banned, player, by_player_name, reason) - - return true -end - ---- Rrmoves a player from temp ban by clearing the stored reason, removing them from jail, and restoring previous roles --- @tparam LuaPlayer player the player who is being removed from temp ban --- @tparam string by_player_name the name of the player who is doing the untemp ban --- @treturn boolean whether the player was successfully removed -function Jail.untemp_ban_player(player, by_player_name) - player = valid_player(player) - if not player then return end - if not by_player_name then return end - - if not temp_bans[player.name] then return end - temp_bans[player.name] = nil - - if has_role(player, 'Jail') then - local roles = old_roles[player.name] - - assign_roles(player, roles, by_player_name, nil, true) - unassign_roles(player, 'Jail', by_player_name, nil, true) - end - - event_emit(Jail.events.on_player_untemp_banned, player, by_player_name) - - return true -end - return Jail \ No newline at end of file