mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Removed Temp ban related stuff
This commit is contained in:
@@ -9,7 +9,6 @@ return {
|
|||||||
player_kicks=true,
|
player_kicks=true,
|
||||||
player_promotes=false,
|
player_promotes=false,
|
||||||
player_jail=true,
|
player_jail=true,
|
||||||
player_temp_ban=true,
|
|
||||||
['config']=true,
|
['config']=true,
|
||||||
['purge']=true,
|
['purge']=true,
|
||||||
['c']=true,
|
['c']=true,
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ Roles.new_role('Moderator','Mod')
|
|||||||
'command/go-to-spawn/always',
|
'command/go-to-spawn/always',
|
||||||
'command/clear-reports',
|
'command/clear-reports',
|
||||||
'command/clear-warnings',
|
'command/clear-warnings',
|
||||||
'command/clear-temp-ban',
|
|
||||||
'command/clear-inventory',
|
'command/clear-inventory',
|
||||||
'command/bonus',
|
'command/bonus',
|
||||||
'command/home',
|
'command/home',
|
||||||
@@ -96,7 +95,6 @@ Roles.new_role('Trainee','TrMod')
|
|||||||
'command/teleport',
|
'command/teleport',
|
||||||
'command/bring',
|
'command/bring',
|
||||||
'command/goto',
|
'command/goto',
|
||||||
'command/temp-ban',
|
|
||||||
'command/give-warning',
|
'command/give-warning',
|
||||||
'command/get-warnings',
|
'command/get-warnings',
|
||||||
'command/get-reports',
|
'command/get-reports',
|
||||||
|
|||||||
@@ -150,25 +150,6 @@ local function jail_player_callback(player,reason)
|
|||||||
Jail.jail_player(selected_player_name,player.name,reason)
|
Jail.jail_player(selected_player_name,player.name,reason)
|
||||||
end
|
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
|
--- Kicks the action player, requires a reason
|
||||||
-- @element kick_player
|
-- @element kick_player
|
||||||
local kick_player = new_button('utility/warning_icon',{'player-list.kick-player'})
|
local kick_player = new_button('utility/warning_icon',{'player-list.kick-player'})
|
||||||
@@ -232,11 +213,6 @@ return {
|
|||||||
reason_callback=jail_player_callback,
|
reason_callback=jail_player_callback,
|
||||||
jail_player
|
jail_player
|
||||||
},
|
},
|
||||||
['command/temp-ban'] = {
|
|
||||||
auth=auth_lower_role,
|
|
||||||
reason_callback=temp_ban_player_callback,
|
|
||||||
temp_ban_player
|
|
||||||
},
|
|
||||||
['command/kick'] = {
|
['command/kick'] = {
|
||||||
auth=auth_lower_role,
|
auth=auth_lower_role,
|
||||||
reason_callback=kick_player_callback,
|
reason_callback=kick_player_callback,
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ give=__1__ was jailed by __2__. Reason: __3__
|
|||||||
remove=__1__ was unjailed by __2__.
|
remove=__1__ was unjailed by __2__.
|
||||||
already-jailed=__1__ is already in jail.
|
already-jailed=__1__ is already in jail.
|
||||||
not-jailed=__1__ is not currently 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]
|
[expcom-report]
|
||||||
player-immune=This player can not be reported.
|
player-immune=This player can not be reported.
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ kill-player=Kill player
|
|||||||
report-player=Report player
|
report-player=Report player
|
||||||
warn-player=Warn player
|
warn-player=Warn player
|
||||||
jail-player=Jail player
|
jail-player=Jail player
|
||||||
temp-ban-player=Temp ban player
|
|
||||||
kick-player=Kick player
|
kick-player=Kick player
|
||||||
ban-player=Ban player
|
ban-player=Ban player
|
||||||
afk-time=__1__% of total map time\nLast moved __2__ ago
|
afk-time=__1__% of total map time\nLast moved __2__ ago
|
||||||
|
|||||||
@@ -158,32 +158,6 @@ if config.player_jail then
|
|||||||
end)
|
end)
|
||||||
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']='<inline>'..player_name,
|
|
||||||
['By']='<inline>'..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']='<inline>'..player_name,
|
|
||||||
['By']='<inline>'..by_player_name
|
|
||||||
}
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Ban and unban
|
--- Ban and unban
|
||||||
if config.player_bans then
|
if config.player_bans then
|
||||||
Event.add(defines.events.on_player_banned, function(event)
|
Event.add(defines.events.on_player_banned, function(event)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
--[[-- Commands Module - Jail
|
--[[-- 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
|
@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}
|
return Commands.error{'expcom-jail.not-jailed', action_player_name_color}
|
||||||
end
|
end
|
||||||
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)
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
--[[-- Control Module - Jail
|
--[[-- Control Module - Jail
|
||||||
- Adds a way to jail players and temp ban players.
|
- Adds a way to jail players.
|
||||||
@control Jail
|
@control Jail
|
||||||
@alias Jail
|
@alias Jail
|
||||||
|
|
||||||
@@ -14,16 +14,11 @@
|
|||||||
-- This will give 'MrBiter' all his roles back and remove him from jail
|
-- 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
|
-- again as above the player name is only used in the event for user feedback
|
||||||
Jail.unjail_player('MrBiter', 'Cooldude2606')
|
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 Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||||
local Game = require 'utils.game' --- @dep utils.game
|
local Game = require 'utils.game' --- @dep utils.game
|
||||||
local Global = require 'utils.global' --- @dep utils.global
|
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 valid_player = Game.get_player_from_any
|
||||||
local assign_roles = Roles.assign_player
|
local assign_roles = Roles.assign_player
|
||||||
@@ -33,7 +28,6 @@ local get_roles = Roles.get_player_roles
|
|||||||
|
|
||||||
local Jail = {
|
local Jail = {
|
||||||
old_roles = {},
|
old_roles = {},
|
||||||
temp_bans = {},
|
|
||||||
events = {
|
events = {
|
||||||
--- When a player is assigned to jail
|
--- When a player is assigned to jail
|
||||||
-- @event on_player_jailed
|
-- @event on_player_jailed
|
||||||
@@ -46,37 +40,22 @@ local Jail = {
|
|||||||
-- @tparam number player_index the index of the player who was unjailed
|
-- @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
|
-- @tparam string by_player_name the name of the player who unjailed the other player
|
||||||
on_player_unjailed=script.generate_event_name(),
|
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 old_roles = Jail.old_roles
|
||||||
local temp_bans = Jail.temp_bans
|
|
||||||
Global.register({
|
Global.register({
|
||||||
old_roles = old_roles,
|
old_roles = old_roles
|
||||||
temp_bans = temp_bans
|
|
||||||
}, function(tbl)
|
}, function(tbl)
|
||||||
Jail.old_roles = tbl.old_roles
|
Jail.old_roles = tbl.old_roles
|
||||||
Jail.temp_bans = tbl.temp_bans
|
|
||||||
old_roles = Jail.old_roles
|
old_roles = Jail.old_roles
|
||||||
temp_bans = Jail.temp_bans
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Used to emit the jail related events
|
--- Used to emit the jail related events
|
||||||
-- @tparam number event the name of the event that will be emited
|
-- @tparam number event the name of the event that will be emited
|
||||||
-- @tparam LuaPlayer player the player who is being acted on
|
-- @tparam LuaPlayer player the player who is being acted on
|
||||||
-- @tparam string by_player_name the player who is doing the action
|
-- @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)
|
local function event_emit(event, player, by_player_name, reason)
|
||||||
script.raise_event(event, {
|
script.raise_event(event, {
|
||||||
name=event,
|
name=event,
|
||||||
@@ -142,73 +121,4 @@ function Jail.unjail_player(player, by_player_name)
|
|||||||
return true
|
return true
|
||||||
end
|
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
|
return Jail
|
||||||
Reference in New Issue
Block a user