mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
Fix issues with util and commands
- Use rawget when testing for locale strings - Use player index 0 for errors in rcon commands
This commit is contained in:
@@ -565,7 +565,7 @@ function Commands._prototype:register(callback)
|
|||||||
local success, traceback = xpcall(Commands._event_handler, debug.traceback, event)
|
local success, traceback = xpcall(Commands._event_handler, debug.traceback, event)
|
||||||
--- @cast traceback string
|
--- @cast traceback string
|
||||||
if not success and not traceback:find("Command does not support rcon usage") then
|
if not success and not traceback:find("Command does not support rcon usage") then
|
||||||
local key = "<" .. table.concat({ event.name, event.player_index, event.tick }, ":") .. ">"
|
local key = "<" .. table.concat({ event.name, event.player_index or 0, event.tick }, ":") .. ">"
|
||||||
local _, msg = Commands.status.internal_error(key)
|
local _, msg = Commands.status.internal_error(key)
|
||||||
Commands.error(msg)
|
Commands.error(msg)
|
||||||
log("Internal Command Error " .. key .. "\n" .. traceback)
|
log("Internal Command Error " .. key .. "\n" .. traceback)
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ end
|
|||||||
--- @param level number? The level of the stack to get the module of, a value of 1 is the caller of this function
|
--- @param level number? The level of the stack to get the module of, a value of 1 is the caller of this function
|
||||||
--- @return string # The name of the module at the given stack frame
|
--- @return string # The name of the module at the given stack frame
|
||||||
function ExpUtil.get_module_name(level)
|
function ExpUtil.get_module_name(level)
|
||||||
local file_within_module = getinfo((level or 1) + 1, "S").short_src:sub(18, -5)
|
local file_within_module = getinfo((level or 1) + 1, "S").short_src:sub(19, -5)
|
||||||
local next_slash = file_within_module:find("/")
|
local next_slash = file_within_module:find("/")
|
||||||
if next_slash then
|
if next_slash then
|
||||||
return file_within_module:sub(1, next_slash - 1)
|
return file_within_module:sub(1, next_slash - 1)
|
||||||
@@ -197,7 +197,7 @@ end
|
|||||||
function ExpUtil.safe_value(value)
|
function ExpUtil.safe_value(value)
|
||||||
local _type = type(value)
|
local _type = type(value)
|
||||||
if _type == "table" then
|
if _type == "table" then
|
||||||
local v1 = value[1]
|
local v1 = rawget(value, 1)
|
||||||
local str = tostring(value)
|
local str = tostring(value)
|
||||||
if type(v1) == "string" and not v1:find("%s")
|
if type(v1) == "string" and not v1:find("%s")
|
||||||
and (v1 == "" or v1 == "?" or v1:find(".+[.].+"))
|
and (v1 == "" or v1 == "?" or v1:find(".+[.].+"))
|
||||||
|
|||||||
Reference in New Issue
Block a user