Bug Fixing Round 3

This commit is contained in:
Cooldude2606
2019-04-19 14:06:08 +01:00
parent 37e040c093
commit 53a74b96e3
12 changed files with 1042 additions and 18 deletions

1002
.luacheckrc Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -6,8 +6,13 @@ require 'config.command_parse_general'
Commands.add_parse('role',function(input,player,reject) Commands.add_parse('role',function(input,player,reject)
if not input then return end if not input then return end
local roles = Roles.config.roles local roles = Roles.config.order
local role = auto_complete(roles,input,true) local rev_roles = {}
for i=#roles,1,-1 do
table.insert(rev_roles,roles[i])
end
local role = auto_complete(rev_roles,input)
role = Roles.get_role_by_name(role)
if not role then if not role then
return reject{'expcore-role.reject-role'} return reject{'expcore-role.reject-role'}
else else

View File

@@ -91,7 +91,7 @@ Roles.new_role('Trainee','TrMod')
'command/goto', 'command/goto',
'command/temp-ban', 'command/temp-ban',
'command/give-warning', 'command/give-warning',
'command/get-warning', 'command/get-warnings',
'command/get-reports', 'command/get-reports',
} }
@@ -120,6 +120,8 @@ Roles.new_role('Donator','Don')
:set_flag('is_spectator') :set_flag('is_spectator')
:set_parent('Veteran') :set_parent('Veteran')
:allow{ :allow{
'command/jail',
'command/unjail'
} }
Roles.new_role('Partner','Part') Roles.new_role('Partner','Part')

View File

@@ -230,7 +230,7 @@ end
function Public.move_items(items,surface,position,radius,chest_type) function Public.move_items(items,surface,position,radius,chest_type)
chest_type = chest_type or 'iron-chest' chest_type = chest_type or 'iron-chest'
surface = surface or game.surfaces[1] surface = surface or game.surfaces[1]
if type(position) ~= 'table' then return end if position and type(position) ~= 'table' then return end
if type(items) ~= 'table' then return end if type(items) ~= 'table' then return end
-- Finds all entities of the given type -- Finds all entities of the given type
local p = position or {x=0,y=0} local p = position or {x=0,y=0}
@@ -438,7 +438,7 @@ end
-- @return the list item found that matches the input -- @return the list item found that matches the input
function Public.auto_complete(options,input,use_key,rtn_key) function Public.auto_complete(options,input,use_key,rtn_key)
local rtn = {} local rtn = {}
if type(input)~= 'string' then return end if type(input) ~= 'string' then return end
input = input:lower() input = input:lower()
for key,value in pairs(options) do for key,value in pairs(options) do
local check = use_key and key or value local check = use_key and key or value

View File

@@ -641,6 +641,8 @@ end
-- @treturn boolean true if the player was added successfully -- @treturn boolean true if the player was added successfully
function Roles._prototype:add_player(player,skip_check,skip_event) function Roles._prototype:add_player(player,skip_check,skip_event)
player = Game.get_player_from_any(player) player = Game.get_player_from_any(player)
-- Default role cant have players added or removed
if self.name == Roles.config.internal.default then return end
-- Check the player is valid, can be skipped but a name must be given -- Check the player is valid, can be skipped but a name must be given
if not player then if not player then
if skip_check then if skip_check then
@@ -673,6 +675,8 @@ end
-- @treturn boolean true if the player was removed successfully -- @treturn boolean true if the player was removed successfully
function Roles._prototype:remove_player(player,skip_check,skip_event) function Roles._prototype:remove_player(player,skip_check,skip_event)
player = Game.get_player_from_any(player) player = Game.get_player_from_any(player)
-- Default role cant have players added or removed
if self.name == Roles.config.internal.default then return end
-- Check the player is valid, can be skipped but a name must be given -- Check the player is valid, can be skipped but a name must be given
if not player then if not player then
if skip_check then if skip_check then

View File

@@ -35,4 +35,5 @@ pre-pre-ban=You are close to reciving a ban; successful ban appeals are unlikely
pre-ban=This your LAST warning before you are BANNED! successful ban appeals are unlikely. pre-ban=This your LAST warning before you are BANNED! successful ban appeals are unlikely.
ban=You were banned for having too many warnings; Vist __1__ to request a ban appeal. ban=You were banned for having too many warnings; Vist __1__ to request a ban appeal.
script-warning=You are reciving script warnings; if you recive too many you will recive a permiment warning (__1__/__2__) script-warning=You are reciving script warnings; if you recive too many you will recive a permiment warning (__1__/__2__)
script-wrning-removed=A script warning has expired (__1__/__2__) script-wrning-removed=A script warning has expired (__1__/__2__)
script-warning-limit=__1__ has recived a permiment warning from the script.

View File

@@ -38,7 +38,7 @@ function Public.jail_player(player,by_player_name)
player = Game.get_player_from_any(player) player = Game.get_player_from_any(player)
if not player then return end if not player then return end
if Roles.player_has_role(player,'Jail') then return end if Roles.player_has_role(player,'Jail') then return end
local old_roles = Role.get_player_roles(player) local old_roles = Roles.get_player_roles(player)
Public.old_roles[player.name] = old_roles Public.old_roles[player.name] = old_roles
Roles.unassign_player(player,old_roles,by_player_name,true) Roles.unassign_player(player,old_roles,by_player_name,true)
Roles.assign_player(player,'Jail',by_player_name,true) Roles.assign_player(player,'Jail',by_player_name,true)

View File

@@ -57,6 +57,9 @@ function Public.remove_player_report(player,by_player_name)
if reports and reports[by_player_name] then if reports and reports[by_player_name] then
event_emit(Public.player_report_removed,player,by_player_name) event_emit(Public.player_report_removed,player,by_player_name)
reports[by_player_name] = nil reports[by_player_name] = nil
if Public.count_player_reports(player) == 0 then
Public.user_reports[player.name] = nil
end
return true return true
end end
return false return false
@@ -115,7 +118,11 @@ function Public.count_player_reports(player,count_callback)
if not player then return end if not player then return end
local reports = Public.user_reports[player.name] or {} local reports = Public.user_reports[player.name] or {}
if not count_callback then if not count_callback then
return #reports local ctn = 0
for _ in pairs(reports) do
ctn=ctn+1
end
return ctn
else else
local ctn = 0 local ctn = 0
for player_name,reason in pairs(reports) do for player_name,reason in pairs(reports) do

View File

@@ -2,6 +2,7 @@ local Game = require 'utils.game'
local Global = require 'utils.global' local Global = require 'utils.global'
local Event = require 'utils.event' local Event = require 'utils.event'
local config = require 'config.warnings' local config = require 'config.warnings'
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
require 'utils.table' require 'utils.table'
local Public = { local Public = {
@@ -195,8 +196,8 @@ Event.add(Public.player_warning_added,function(event)
elseif type(action) == 'table' then elseif type(action) == 'table' then
-- {locale,by_player_name,number_of_warning,...} -- {locale,by_player_name,number_of_warning,...}
local current_action = table.deep_copy(action) local current_action = table.deep_copy(action)
table.insert(current_action,1,event.by_player_name) table.insert(current_action,2,event.by_player_name)
table.insert(current_action,1,event.warning_count) table.insert(current_action,3,event.warning_count)
player.print(current_action) player.print(current_action)
elseif type(action) == 'string' then elseif type(action) == 'string' then
player.print(action) player.print(action)
@@ -208,6 +209,8 @@ Event.add(Public.player_temp_warning_added,function(event)
local player = Game.get_player_by_index(event.player_index) local player = Game.get_player_by_index(event.player_index)
if event.temp_warning_count > config.temp_warning_limit then if event.temp_warning_count > config.temp_warning_limit then
Public.add_warnings(event.player_index,event.by_player_name) Public.add_warnings(event.player_index,event.by_player_name)
local player_name_color = format_chat_player_name(player)
game.print{'warnings.script-warning-limit',player_name_color}
else else
player.print{'warnings.script-warning',event.temp_warning_count,config.temp_warning_limit} player.print{'warnings.script-warning',event.temp_warning_count,config.temp_warning_limit}
end end

View File

@@ -48,13 +48,12 @@ end)
Commands.new_command('clear-temp-ban','Removes temp ban from a player; this will not restore they items.') Commands.new_command('clear-temp-ban','Removes temp ban from a player; this will not restore they items.')
:add_param('player',false,'player-role') :add_param('player',false,'player-role')
:add_param('reason',false)
:add_alias('untemp-ban','remove-temp-ban') :add_alias('untemp-ban','remove-temp-ban')
:enable_auto_concat() :enable_auto_concat()
:register(function(player,action_player,reason,raw) :register(function(player,action_player,raw)
local action_player_name_color = format_chat_player_name(action_player) local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player) local by_player_name_color = format_chat_player_name(player)
if JailControl.clear_temp_ban_player(action_player,player.name,reason) then if JailControl.clear_temp_ban_player(action_player,player.name) then
game.print{'exp-commands.jail-temp-ban-clear',action_player_name_color,by_player_name_color} game.print{'exp-commands.jail-temp-ban-clear',action_player_name_color,by_player_name_color}
else else
return Commands.error{'exp-commands.jail-not-temp-banned',action_player_name_color} return Commands.error{'exp-commands.jail-not-temp-banned',action_player_name_color}

View File

@@ -8,7 +8,7 @@ Commands.new_command('report','Reports a player and notifies moderators')
:add_param('player',false,function(input,player,reject) :add_param('player',false,function(input,player,reject)
input = Commands.parse('player',input,player,reject) input = Commands.parse('player',input,player,reject)
if not input then return end if not input then return end
if Roles.player_has_flag(player,'report-immune') then if Roles.player_has_flag(input,'report-immune') then
return reject{'exp-commands.report-player-immune'} return reject{'exp-commands.report-player-immune'}
else else
return input return input
@@ -45,7 +45,8 @@ Commands.new_command('get-reports','Gets a list of all reports that a player has
Commands.print{'exp-commands.report-player-count-title'} Commands.print{'exp-commands.report-player-count-title'}
for player_name,reports in pairs(user_reports) do for player_name,reports in pairs(user_reports) do
local player_name_color = format_chat_player_name(player_name) local player_name_color = format_chat_player_name(player_name)
Commands.print{'exp-commands.report-list',player_name_color,#reports} local report_count = ReportsControl.count_player_reports(player_name)
Commands.print{'exp-commands.report-list',player_name_color,report_count}
end end
end end
end) end)
@@ -55,7 +56,7 @@ Commands.new_command('clear-reports','Clears all reports from a player or just t
:add_param('from-player',true,'player') :add_param('from-player',true,'player')
:register(function(player,action_player,from_player,raw) :register(function(player,action_player,from_player,raw)
if from_player then if from_player then
if not ReportsControl.remove_player_report(action_player,from_player) then if not ReportsControl.remove_player_report(action_player,from_player.name) then
return Commands.error{'exp-commands.report-not-reported'} return Commands.error{'exp-commands.report-not-reported'}
end end
else else

View File

@@ -49,8 +49,8 @@ end)
Commands.new_command('clear-warnings','Clears all warnings (and script warnings) from a player') Commands.new_command('clear-warnings','Clears all warnings (and script warnings) from a player')
:add_param('player',false,'player') :add_param('player',false,'player')
:register(function(player,action_player,raw) :register(function(player,action_player,raw)
WarningsControl.clear_warnings(player,player.name) WarningsControl.clear_warnings(action_player,player.name)
WarningsControl.clear_temp_warnings(player,player.name) WarningsControl.clear_temp_warnings(action_player,player.name)
local action_player_name_color = format_chat_player_name(action_player) local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player) local by_player_name_color = format_chat_player_name(player)
game.print{'exp-commands.warnings-cleared',action_player_name_color,by_player_name_color} game.print{'exp-commands.warnings-cleared',action_player_name_color,by_player_name_color}