-- @author QueuedResonance 2022

local Callbacks = {}

local ServerCommands = {}
local IgnoredCommands = {}

local CommandName = ZomboRutConfig.CommandName

local function onClientCommand(module, command, player, args)
	if not isServer() or module ~= CommandName then return end

	if not ServerCommands[command] and not IgnoredCommands[command] then
		ServerCommands[command] = require(string.format("ZomboRut/ServerCommands/%s", command))
	end

	if ServerCommands[command] then
		ServerCommands[command](player, args)
	elseif not IgnoredCommands[command] then
		IgnoredCommands[command] = true
	end
end

function Callbacks:sendServerCommand(command, ...)
	if not isServer() then return end

	sendServerCommand(CommandName, command, {...})
end

Events.OnClientCommand.Add(onClientCommand)

return Callbacks