From f9883800962e4e77e9bcd6aed2ccf814313dfac8 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 9 Nov 2018 15:44:01 +0000 Subject: [PATCH] Fixed Some Admin Commands --- modules/ExpGamingAdmin/AdminLib/control.lua | 7 ++++--- modules/ExpGamingAdmin/Commands/src/jail.lua | 4 ++-- modules/ExpGamingAdmin/Commands/src/reports.lua | 2 +- modules/ExpGamingAdmin/Commands/src/tempban.lua | 2 +- modules/ExpGamingAdmin/Commands/src/warnings.lua | 2 +- modules/ExpGamingAdmin/Jail/control.lua | 1 + modules/ExpGamingAdmin/Reports/control.lua | 5 ++--- modules/ExpGamingAdmin/Warnings/control.lua | 4 +--- modules/ExpGamingCore/Role/config.lua | 3 ++- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/ExpGamingAdmin/AdminLib/control.lua b/modules/ExpGamingAdmin/AdminLib/control.lua index 493845e4..e060176b 100644 --- a/modules/ExpGamingAdmin/AdminLib/control.lua +++ b/modules/ExpGamingAdmin/AdminLib/control.lua @@ -18,6 +18,7 @@ local Admin = { if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Admin','ExpGamingAdmin.AdminLib') end end, actions={}, + action_functions={}, action_names={} } @@ -60,13 +61,13 @@ end function Admin.add_action(action,callback) verbose('Added admin action: '..action) - table.insert(Admin.action_names,action) - Admin.actions[string.lower(action)] = callback + Admin.acctions[string.lower(action)] = table.insert(Admin.action_names,action) + Admin.action_functions[string.lower(action)] = callback end function Admin.take_action(action,player,by_player,reason) if Admin[action] then Admin[action](player,by_player,reason) end - if Admin.actions[string.lower(action)] then Admin.actions[string.lower(action)](player,by_player,reason) end + if Admin.action_functions[string.lower(action)] then Admin.action_functions[string.lower(action)](player,by_player,reason) end end function Admin.clear_player(player,by_player) diff --git a/modules/ExpGamingAdmin/Commands/src/jail.lua b/modules/ExpGamingAdmin/Commands/src/jail.lua index dd160d5d..80017eb4 100644 --- a/modules/ExpGamingAdmin/Commands/src/jail.lua +++ b/modules/ExpGamingAdmin/Commands/src/jail.lua @@ -11,7 +11,7 @@ commands.add_command('jail', 'Jails a player', { }, function(event,args) local player = args.player local reason = args.reason - if Role.allowed(player,'no-report') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end + if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end if Admin.is_banned(player) then player_return{'ExpGamingCore_Command.cant-report-ban',args.player} return commands.error end Admin.jail(player,event.player_index,reason) end) @@ -23,6 +23,6 @@ commands.add_command('unjail', 'Returns a player\'s old rank', { ['player']={true,'player'} }, function(event,args) local player = args.player - if Admin.is_banned(player) then player_return({'ExpGamingCore_Command.cant-report-ban',args.player}) return commands.error end + if Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingCore_Command.cant-report-ban',args.player}) return commands.error end Server.interface(Role.revert,true,player,event.player_index,2) end) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Commands/src/reports.lua b/modules/ExpGamingAdmin/Commands/src/reports.lua index a6cdb87b..0355c514 100644 --- a/modules/ExpGamingAdmin/Commands/src/reports.lua +++ b/modules/ExpGamingAdmin/Commands/src/reports.lua @@ -13,7 +13,7 @@ commands.add_command('report', 'Reports a player', { local player = args.player local reason = args.reason if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end - if Role.allowed(player,'no-report') then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end + if Role.has_flag(player,'not_reportable') then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end for _,report in pairs(global.addons.reports.reports) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end end for _,report in pairs(global.addons.reports.varified) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end end Admin.report(player,event.player_index,reason) diff --git a/modules/ExpGamingAdmin/Commands/src/tempban.lua b/modules/ExpGamingAdmin/Commands/src/tempban.lua index 4fabd475..00e8b43c 100644 --- a/modules/ExpGamingAdmin/Commands/src/tempban.lua +++ b/modules/ExpGamingAdmin/Commands/src/tempban.lua @@ -10,6 +10,6 @@ commands.add_command('temp-ban', 'Temporarily ban a player', { }, function(event,args) local player = args.player local reason = args.reason - if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end + if Admin.is_banned(player) and Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end Admin.temp_ban(player,event.player_index,reason) end) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Commands/src/warnings.lua b/modules/ExpGamingAdmin/Commands/src/warnings.lua index 737df1c7..02b548e5 100644 --- a/modules/ExpGamingAdmin/Commands/src/warnings.lua +++ b/modules/ExpGamingAdmin/Commands/src/warnings.lua @@ -12,7 +12,7 @@ commands.add_command('warn', 'Gives a player a warning', { local player = args.player local reason = args.reason if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player} return commands.error end - if Role.allowed(player,'no-report') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end + if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end Admin.give_warning(player,event.player_index,reason) end) diff --git a/modules/ExpGamingAdmin/Jail/control.lua b/modules/ExpGamingAdmin/Jail/control.lua index 72adb0e5..7d47d602 100644 --- a/modules/ExpGamingAdmin/Jail/control.lua +++ b/modules/ExpGamingAdmin/Jail/control.lua @@ -31,6 +31,7 @@ function Admin.jail(player,by_player,reason) local player = Game.get_player(player) local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '' local reason = Admin.create_reason(reason,by_player_name) + Admin.set_banned(player,'jail') if Sync then Sync.emit_embeded{ title='Player Jail', color=Color.to_hex(defines.textcolor.med), diff --git a/modules/ExpGamingAdmin/Reports/control.lua b/modules/ExpGamingAdmin/Reports/control.lua index 320ccbbf..5c5b6f51 100644 --- a/modules/ExpGamingAdmin/Reports/control.lua +++ b/modules/ExpGamingAdmin/Reports/control.lua @@ -59,8 +59,7 @@ local function cheak_reports(player) local player = Game.get_player(player) if not player then return end local reports = Admin.count_reports(player) - if reports >= reports_needed_for_jail and global.actions[player.name] ~= 'report-jail' and Role.get_highest(player).group.name ~= 'Jail' then - global.actions[player.name] = actions.report + if reports >= reports_needed_for_jail and Role.get_highest(player).group.name ~= 'Jail' then Admin.jail(player,'','Too many user reports. Contact an Admin to be unjailed.') end end @@ -84,7 +83,7 @@ end function Admin.report(player,by_player,reason) local player, by_player_name = valid_players(player,by_player) - if not player or Role.allowed(player,'no-report') then return end + if not player or Role.has_flag(player,'not_reportable') then return end if Admin.is_banned(by_player) or Role.has_flag(by_player,'is_jail') then return end if Role.has_flag(by_player,'is_varified') then global.varified[player.name] = global.varified[player.name] or {} diff --git a/modules/ExpGamingAdmin/Warnings/control.lua b/modules/ExpGamingAdmin/Warnings/control.lua index 5514ad60..df028655 100644 --- a/modules/ExpGamingAdmin/Warnings/control.lua +++ b/modules/ExpGamingAdmin/Warnings/control.lua @@ -81,12 +81,10 @@ local function give_punishment(player,by_player,reason) player_return(message,colour,player) Admin.report(player,'',reason) elseif punishment[1] == 'kick' then - global.actions[player.name] = actions.kick Admin.kick(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason) elseif punishment[1] == 'temp-ban' then Admin.temp_ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason) elseif punishment[1] == 'ban' then - global.actions[player.name] = actions.ban Admin.ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason) end end @@ -114,7 +112,7 @@ end function Admin.clear_warings(player,by_player,no_emit) local player, by_player_name = valid_players(player,by_player) if not player then return end - global[player.name]=0 + global[player.name]=nil if not no_emit and Sync then Sync.emit_embeded{ title='Player Clear', diff --git a/modules/ExpGamingCore/Role/config.lua b/modules/ExpGamingCore/Role/config.lua index 3e5ded37..ea8db9ec 100644 --- a/modules/ExpGamingCore/Role/config.lua +++ b/modules/ExpGamingCore/Role/config.lua @@ -32,6 +32,7 @@ Role{ is_admin=true, is_spectator=true, is_donator=true, + not_reportable=true, allow={} } Role{ @@ -43,6 +44,7 @@ Role{ is_admin=true, is_spectator=true, is_donator=true, + not_reportable=true, allow={ ['interface']=true, ['cheat-mode']=true @@ -93,7 +95,6 @@ Role{ allow={ ['go-to']=true, ['bring']=true, - ['no-report']=true, ['set-home']=false, ['home']=false, ['return']=false,