local function W(W,o,O)local l l=function(W,o)if o then for W,O in ipairs(W:GetChildren())do local b=O:Clone()if O:IsA("\070\111\108\100\101\114")then local W=o:FindFirstChild(O.Name)if not W then b.Parent=o else l(O,W)end else b.Parent=o end end else warn("\077\105\115\115\105\110\103 \112\097\114\101\110\116 \116\111 \117\110\112\097\099\107 \105\110\116\111 \102\111\114 "..tostring(W))end end l(W,o)end local function o()warn("\066\101\103\105\110\110\105\110\103 \065\100\111\110\105\115 \099\108\101\097\110\117\112 \038 \115\104\117\116\100\111\119\110 \112\114\111\099\101\115\115\046\046\046")server.Model.Name="\065\100\111\110\105\115\095\076\111\097\100\101\114"server.Model.Parent=service.ServerScriptService server.Running=false pcall(service.Threads.StopAll)pcall(function()for W,o in pairs(RbxEvents)do print("\068\105\115\099\111\110\110\101\099\116\105\110\103 \101\118\101\110\116")o:Disconnect()table.remove(RbxEvents,W)end end)if server.Core and server.Core.RemoteEvent then pcall(server.Core.DisconnectEvent)end warn("\085\110\108\111\097\100\105\110\103 \099\111\109\112\108\101\116\101")end server={Running=true,Modules={};Pcall=Pcall;cPcall=cPcall,Routine=Routine;LogError=logError;ErrorLogs=ErrorLogs,ServerStartTime=os.time();CommandCache={}}locals={server=server,CodeName="",Settings=server.Settings;HookedEvents=HookedEvents,ErrorLogs=ErrorLogs,logError=logError,origEnv=origEnv;Routine=Routine;Folder=Folder;GetEnv=GetEnv;cPcall=cPcall,Pcall=Pcall}service=(require(Folder.Shared.Service))(function(W,o,O,...)local l={...}if W=="\077\101\116\104\111\100\069\114\114\111\114"then if server and(server.Logs and server.Logs.AddLog)then server.Logs.AddLog("\083\099\114\105\112\116",{Text="\067\097\099\104\101\100 \109\101\116\104\111\100 \100\111\101\115\110\'\116 \109\097\116\099\104 \102\111\117\110\100 \109\101\116\104\111\100\058 "..tostring(l[1]),Desc="\077\101\116\104\111\100\058 "..tostring(l[1])})end elseif W=="\083\101\114\118\101\114\069\114\114\111\114"then logError("\083\101\114\118\101\114",o)elseif W=="\084\097\115\107\069\114\114\111\114"then logError("\084\097\115\107",o)end end,function(W,o,O)if not isModule(W)and(W~=server.Loader and(W~=server.Dropper and(W~=server.Runner and(W~=server.Model and(W~=script and(W~=Folder and o==nil))))))then O.UnHook()end end,ServiceSpecific,GetEnv(nil,{server=server}))

local function LoadPackage(package, folder, runNow)
	--// runNow - Run immediately after unpacking (default behavior is to just unpack (((only needed if loading after startup))))
	--// runNow currently not used (limitations) so all packages must be present at server startup
	local unpack; unpack = function(curFolder, unpackInto)
		if unpackInto then
			for i,obj in ipairs(curFolder:GetChildren()) do
				local clone = obj:Clone();
				if obj:IsA("Folder") then
					local realFolder = unpackInto:FindFirstChild(obj.Name);
					if not realFolder then
						clone.Parent = unpackInto;
					else
						unpack(obj, realFolder);
					end
				else
					clone.Parent = unpackInto;
				end
			end
		else
			warn("Missing parent to unpack into for ".. tostring(curFolder));
		end
	end;

	unpack(package, folder);
end;

local function CleanUp()
	--local env = getfenv(2)
	--local ran,ret = pcall(function() return env.script:GetFullName() end)
	warn("Beginning Adonis cleanup & shutdown process...")
	--warn("CleanUp called from "..tostring((ran and ret) or "Unknown"))
	--local loader = server.Core.ClientLoader
	server.Model.Name = "Adonis_Loader"
	server.Model.Parent = service.ServerScriptService
	server.Running = false

	pcall(service.Threads.StopAll)
	pcall(function()
		for i,v in pairs(RbxEvents) do
			print("Disconnecting event")
			v:Disconnect()
			table.remove(RbxEvents, i)
		end
	end)
	--loader.Archivable = false
	--loader.Disabled = true
	--loader:Destroy()
	if server.Core and server.Core.RemoteEvent then
		pcall(server.Core.DisconnectEvent);
	end

	--[[delay(0, function()
		for i,v in next,server do
			server[i] = nil; --// Try to break it to prevent any potential hanging issues; Not very graceful...
		end
	--end)--]]

	warn("Unloading complete")
end;

server = {
	Running = true;
	Modules = {};
	Pcall = Pcall;
	cPcall = cPcall;
	Routine = Routine;
	LogError = logError;
	ErrorLogs = ErrorLogs;
	ServerStartTime = os.time();
	CommandCache = {};
};

locals = {
	server = server;
	CodeName = "";
	Settings = server.Settings;
	HookedEvents = HookedEvents;
	ErrorLogs = ErrorLogs;
	logError = logError;
	origEnv = origEnv;
	Routine = Routine;
	Folder = Folder;
	GetEnv = GetEnv;
	cPcall = cPcall;
	Pcall = Pcall;
};

service = require(Folder.Shared.Service)(function(eType, msg, desc, ...)
	local extra = {...}
	if eType == "MethodError" then
		if server and server.Logs and server.Logs.AddLog then
			server.Logs.AddLog("Script", {
				Text = "Cached method doesn't match found method: "..tostring(extra[1]);
				Desc = "Method: "..tostring(extra[1])
			})
		end
	elseif eType == "ServerError" then
		--print("Server error")
		logError("Server", msg)
	elseif eType == "TaskError" then
		--print("Task error")
		logError("Task", msg)
	end
end, function(c, parent, tab)
	if not isModule(c) and c ~= server.Loader and c ~= server.Dropper and c ~= server.Runner and c ~= server.Model and c ~= script and c ~= Folder and parent == nil then
		tab.UnHook()
	end
end, ServiceSpecific, GetEnv(nil, {server = server}))
