Skip to content

Commit

Permalink
refactor(items): ignore non-string item names in getItem
Browse files Browse the repository at this point in the history
People repeatedly send number values here.
I've yet to figure out their thought patterns, though they may lack any sort of conscious thought.
  • Loading branch information
thelindat committed Jun 20, 2023
1 parent b476f61 commit 1a17f23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions modules/items/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ exports('displayMetadata', displayMetadata)
---@param name string?
---@return table?
local function getItem(_, name)
if name then
name = name:lower()
if not name then return Items end

if name:sub(0, 7) == 'weapon_' then
name = name:upper()
end
if type(name) ~= 'string' then return end

return Items[name]
end
name = name:lower()

if name:sub(0, 7) == 'weapon_' then
name = name:upper()
end

return Items
return Items[name]
end

setmetatable(Items --[[@as table]], {
Expand Down
16 changes: 8 additions & 8 deletions modules/items/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ local trash = {
---@param name string?
---@return table?
local function getItem(_, name)
if name then
name = name:lower()
if not name then return ItemList end

if name:sub(0, 7) == 'weapon_' then
name = name:upper()
end
if type(name) ~= 'string' then return end

return ItemList[name]
end
name = name:lower()

if name:sub(0, 7) == 'weapon_' then
name = name:upper()
end

return ItemList
return ItemList[name]
end

setmetatable(Items --[[@as table]], {
Expand Down

0 comments on commit 1a17f23

Please sign in to comment.