Skip to content

Commit

Permalink
Load plugins asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
Expertcoderz committed Jan 11, 2025
1 parent 258b376 commit be4b279
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions MainModule/Client/Client.luau
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ do
task.wait(1)
service.Player:Kick(info)
end)

if not isStudio then
spawn(pcall, function()
task.wait(5)
Expand Down Expand Up @@ -575,7 +575,7 @@ return service.NewProxy({
for i, line in ipairs(client.Changelog) do
client.FormattedChangelog[i] = applyColour(line)
end

--// Setup MatIcons
do
local MaterialIcons = oldReq(service_UnWrap(client.Shared.MatIcons))
Expand Down Expand Up @@ -752,7 +752,9 @@ return service.NewProxy({
continue
end

LoadModule(module, false, { script = module, cPcall = client.cPcall }) --noenv
task.defer(LoadModule, module, false, { --noenv
script = module, cPcall = client.cPcall
})
end

--// We need to do some stuff *after* plugins are loaded (in case we need to be able to account for stuff they may have changed before doing something, such as determining the max length of remote commands)
Expand Down
4 changes: 2 additions & 2 deletions MainModule/Server/Server.luau
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ return service.NewProxy({
server.FormattedChangelog[i] = applyColour(line)
end

--// Setup MaterialIcons
--// Setup MaterialIcons
do
local MaterialIcons = require(server.Shared.MatIcons)
server.MatIcons = setmetatable({}, {
Expand Down Expand Up @@ -712,7 +712,7 @@ return service.NewProxy({
end

for _, module in ipairs(data.ServerPlugins or {}) do
xpcall(LoadModule, function(reason)
task.defer(xpcall, LoadModule, function(reason)
warn(`The plugin {type(module) == "string" and string.sub(module, 1, 15) or module} failed to load! Reason: {reason}`)
logError(`The plugin {type(module) == "string" and string.sub(module, 1, 15) or module} failed to load! Reason: {reason}`)
table.insert(server.messages, {
Expand Down

0 comments on commit be4b279

Please sign in to comment.