Handle nil APIs

This commit is contained in:
boatbomber 2023-01-09 11:24:51 -05:00
parent 9d412a3273
commit 5cf9a7de42

View file

@ -40,7 +40,10 @@ function API.new(app)
Rojo._apiDescriptions.ProjectName = "The name of the project that the plugin is connected to" Rojo._apiDescriptions.ProjectName = "The name of the project that the plugin is connected to"
Rojo.Version = table.clone(Config.version) Rojo.Version = table.clone(Config.version)
Rojo._apiDescriptions.Version = "The version of the plugin"
Rojo.ProtocolVersion = Config.protocolVersion Rojo.ProtocolVersion = Config.protocolVersion
Rojo._apiDescriptions.ProtocolVersion = "The protocol version that the plugin is using"
function Rojo:_updateProperty(property: string, value: any?) function Rojo:_updateProperty(property: string, value: any?)
local oldValue = Rojo[property] local oldValue = Rojo[property]
@ -201,7 +204,7 @@ function API.new(app)
-- Sanitize request -- Sanitize request
local sanitizedApis = {} local sanitizedApis = {}
for _, api in apis do for _, api in apis do
if Rojo[api] ~= nil then if Rojo._apiDescriptions[api] ~= nil then
table.insert(sanitizedApis, api) table.insert(sanitizedApis, api)
else else
warn(string.format("Rojo.%s is not a valid API", tostring(api))) warn(string.format("Rojo.%s is not a valid API", tostring(api)))
@ -330,7 +333,7 @@ function API.new(app)
end end
-- Existence check -- Existence check
if Rojo[key] == nil then if Rojo._apiDescriptions[key] == nil then
warn(string.format("Rojo.%s is not a valid API", tostring(key))) warn(string.format("Rojo.%s is not a valid API", tostring(key)))
return nil return nil
end end