Add descriptions to framework job count functions

Added @description annotations to all relevant functions and event handlers in both client and server framework modules for improved code documentation and clarity.
This commit is contained in:
MrNewb committed 2025-10-19 22:21:22 -04:00
1 parent 19911d9173
commit 61f4d05f0a
2 files changed
+19 -10

No files matched your search

+7 -3
View File
@@ -3,18 +3,22 @@ Framework = Framework or {}
local currentJobCounts = GlobalState.jobcounts or {} local currentJobCounts = GlobalState.jobcounts or {}
---@description State bag change handler to update job counts when global state changes
---@param bagName string
---@param key string
---@param value table|nil
AddStateBagChangeHandler('jobcounts', 'global', function(bagName, key, value) AddStateBagChangeHandler('jobcounts', 'global', function(bagName, key, value)
if not value then currentJobCounts = {} return end if not value then currentJobCounts = {} return end
currentJobCounts = value currentJobCounts = value
end) end)
---This will get the name of the in use resource. ---@description This will get the name of the in use resource.
---@return string ---@return string
Framework.GetResourceName = function() Framework.GetResourceName = function()
return 'default' return 'default'
end end
---This is an internal function that will be used to retrieve job counts later. ---@description This is an internal function that will be used to retrieve job counts later.
---@param jobName string ---@param jobName string
---@return number ---@return number
Framework.GetJobCount = function(jobName) Framework.GetJobCount = function(jobName)
@@ -22,7 +26,7 @@ Framework.GetJobCount = function(jobName)
return currentJobCounts[jobName] return currentJobCounts[jobName]
end end
---This will allow passing a table of job names and returning a sum of the total count. ---@description This will allow passing a table of job names and returning a sum of the total count.
---@param tbl table ---@param tbl table
---@return number ---@return number
Framework.GetJobCountTotal = function(tbl) Framework.GetJobCountTotal = function(tbl)
+12 -7
View File
@@ -7,13 +7,13 @@ local globalState = GlobalState
globalState.jobcounts = {} globalState.jobcounts = {}
---This will get the name of the in use resource. ---@description This will get the name of the in use resource.
---@return string ---@return string
Framework.GetResourceName = function() Framework.GetResourceName = function()
return 'default' return 'default'
end end
---This is an internal function that will be used to retrieve job counts later. ---@description This is an internal function that will be used to retrieve job counts later.
---@param jobName string ---@param jobName string
---@return number ---@return number
Framework.GetJobCount = function(jobName) Framework.GetJobCount = function(jobName)
@@ -25,7 +25,7 @@ Framework.GetJobCount = function(jobName)
return count return count
end end
---This will allow passing a table of job names and returning a sum of the total count. ---@description This will allow passing a table of job names and returning a sum of the total count.
---@param tbl any ---@param tbl any
---@return number ---@return number
Framework.GetJobCountTotal = function(tbl) Framework.GetJobCountTotal = function(tbl)
@@ -36,7 +36,7 @@ Framework.GetJobCountTotal = function(tbl)
return total return total
end end
---This will return a list of player sources for a given job. ---@description This will return a list of player sources for a given job.
---@param jobName string ---@param jobName string
---@return table ---@return table
Framework.GetPlayerSourcesByJob = function(jobName) Framework.GetPlayerSourcesByJob = function(jobName)
@@ -48,7 +48,7 @@ Framework.GetPlayerSourcesByJob = function(jobName)
return sources return sources
end end
---This will update the cached tables for job counts. ---@description This will update the cached tables for job counts.
---This is used to track how many players are in a job. ---This is used to track how many players are in a job.
---@param src number ---@param src number
---@param jobName string ---@param jobName string
@@ -69,13 +69,13 @@ Framework.AddJobCount = function(src, jobName)
return true return true
end end
---This will return the job name for a given source. ---@description This will return the job name for a given source.
---@param src number ---@param src number
Framework.SearchJobCountBySource = function(src) Framework.SearchJobCountBySource = function(src)
return invertedJobsRegisteredTable[src] return invertedJobsRegisteredTable[src]
end end
---This will remove the job count for a given source. ---@description This will remove the job count for a given source.
---@param src number ---@param src number
---@param jobName string | nil ---@param jobName string | nil
Framework.RemoveJobCount = function(src, jobName) Framework.RemoveJobCount = function(src, jobName)
@@ -101,12 +101,17 @@ Framework.RemoveJobCount = function(src, jobName)
return true return true
end end
---@description Event handler for when a player's job changes, updates job counts accordingly
---@param src number
---@param newJobName string
AddEventHandler('community_bridge:Server:OnPlayerJobChange', function(src, newJobName) AddEventHandler('community_bridge:Server:OnPlayerJobChange', function(src, newJobName)
local previousJob = invertedJobsRegisteredTable[src] local previousJob = invertedJobsRegisteredTable[src]
if previousJob then Framework.RemoveJobCount(src, previousJob) end if previousJob then Framework.RemoveJobCount(src, previousJob) end
if newJobName then Framework.AddJobCount(src, newJobName) end if newJobName then Framework.AddJobCount(src, newJobName) end
end) end)
---@description Event handler for when a player unloads, removes them from job counts
---@param src number
AddEventHandler('community_bridge:Server:OnPlayerUnload', function(src) AddEventHandler('community_bridge:Server:OnPlayerUnload', function(src)
Framework.RemoveJobCount(src) Framework.RemoveJobCount(src)
end) end)