-- ALEX WAS HERE LOL


local u1 = nil;
coroutine.wrap(function()
	u1 = require(game.ReplicatedStorage:WaitForChild("Resources"));
end)();
local u2
u2 = {
	HasAccess = function(p1, p2)
		if not u1.Saving.Get(p1) then
			return false;
		end;
		local v1 = u1.Directory.Worlds[p2];
		if not v1 then
			return false;
		end;
		local l__requiredArea__2 = v1.requiredArea;
		if l__requiredArea__2 and not u2.HasArea(p1, l__requiredArea__2) then
			return false;
		end;
		return true;
	end
};
local l____WORLDS__3 = game.ServerStorage:WaitForChild("__WORLDS");
function u2.Load(p3, p4)
	if p3 then
		local v3 = u1.Saving.Get(p3);
		local l__PlayerGui__4 = p3:FindFirstChild("PlayerGui");
		if v3 and l__PlayerGui__4 then
			local v5 = u1.Directory.Worlds[p4];
			if not v5 or v5.disabled then
				print("Tried to load world " .. p4 .. ", doesn't exist", true);
				p4 = "Spawn";
			end;
			if not u1.Shared.IsTradingPlaza and p4 == "Trading Plaza" then
				p4 = "Spawn";
			elseif u1.Shared.IsTradingPlaza then
				p4 = "Trading Plaza";
			end;
			if not u2.HasAccess(p3, p4) then
				print("Changing " .. p3.Name .. "'s world to Spawn because requested world is locked");
				p4 = "Spawn";
			end;
			if p4 == 'Void' and not v3.HackerPortalUnlocked then
				print("Changing " .. p3.Name .. "'s world to Spawn because he does not have the hacker portal unlocked");
				p4 = "Spawn";
			end
			if p4 == "Fantasy" then
				coroutine.wrap(function()
					wait(3);
					if not u2.HasArea(p3, "Enchanted Forest") then
						u2.GiveArea(p3, "Enchanted Forest");
						u2.GiveArea(p3, "Fantasy Shop");
						u1.Achievements.Add(p3, "Unlock Fantasy", 1);
					end;
				end)();
			elseif p4 == "Tech" then
				coroutine.wrap(function()
					wait(3);
					if not u2.HasArea(p3, "Tech City") then
						u2.GiveArea(p3, "Tech City");
						u2.GiveArea(p3, "Tech Shop");
						u1.Achievements.Add(p3, "Unlock Tech", 1);
					end;
				end)();
			elseif p4 == 'Secret' then
				coroutine.wrap(function()
					wait(3);
					u2.GiveArea(p3, "Cat");
				end)();
			elseif p4 == "Trading Plaza" then
				coroutine.wrap(function()
					wait(3);
					u2.GiveArea(p3, "Plaza Presents");
					u1.Achievements.Add(p3, "Join Trading Plaza", 1);
				end)();
			elseif p4 == "Halloween Event" then
				coroutine.wrap(function()
					wait(3);
					u2.GiveArea(p3, "Halloween");
					u1.Achievements.Add(p3, "Halloween 2021", 1);
				end)();
			elseif p4 == "Christmas Event" then
				coroutine.wrap(function()
					wait(3);
					u2.GiveArea(p3, "Christmas");
					u1.Achievements.Add(p3, "Christmas 2021", 1);
				end)();
			elseif p4 == "Void" then
				coroutine.wrap(function()
					wait(3);
					if not u2.HasArea(p3, "The Void") then
						u2.GiveArea(p3, "The Void");
						u1.Achievements.Add(p3, "Unlock Void", 1);
					end;
				end)();
			elseif p4 == "Axolotl Ocean" then
				coroutine.wrap(function()
					wait(3);
					if not u2.HasArea(p3, "Axolotl Ocean") then
						u2.GiveArea(p3, "Axolotl Ocean");
						u1.Achievements.Add(p3, "Unlock Axolotl Ocean", 1);
					end;
				end)();
			elseif p4 == "Pixel" then
				coroutine.wrap(function()
					wait(3);
					if not u2.HasArea(p3, "Pixel Forest") then
						u2.GiveArea(p3, "Pixel Forest");
						u1.Achievements.Add(p3, "Unlock Pixel World", 1);
					end;
				end)();
			end;
			local v6 = l____WORLDS__3:FindFirstChild(p4):Clone();
			v6.Name = "__MAP";
			v6.Parent = l__PlayerGui__4;
			v3.World = p4;
			u1.Signal.Fire("World Changed", p3, p4);
		end;
	end;
end;
function u2.GetNetworkList(p5)
	local v7 = {};
	for v8, v9 in ipairs(game.Players:GetPlayers()) do
		local v10 = u1.Saving.Get(v9);
		if v10 and p5 == v10.World then
			table.insert(v7, v9);
		end;
	end;
	return v7;
end;
function u2.HasArea(p6, p7)
	local v11 = u1.Saving.Get(p6);
	if v11 and u1.Functions.SearchDictionary(v11.AreasUnlocked, p7) then
		return true;
	end;
	return false;
end;
function u2.GiveArea(p8, p9)
	local v12 = u1.Saving.Get(p8);
	if not v12 or not (not u2.HasArea(p8, p9)) then
		return;
	end;
	table.insert(v12.AreasUnlocked, p9);
	return true;
end;
u1.Network.Fired('Request World'):Connect(u2.Load)
return u2;
