Ejemplo n.º 1
0
void cPluginManager::InsertDefaultPlugins(cSettingsRepositoryInterface & a_Settings)
{
	a_Settings.AddKeyName("Plugins");
	a_Settings.AddKeyComment("Plugins", " Plugin=Debuggers");
	a_Settings.AddKeyComment("Plugins", " Plugin=HookNotify");
	a_Settings.AddKeyComment("Plugins", " Plugin=APIDump");
	a_Settings.AddValue("Plugins", "Plugin", "Core");
	a_Settings.AddValue("Plugins", "Plugin", "ChatLog");
}
Ejemplo n.º 2
0
void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings)
{
	// First get the default world
	AString DefaultWorldName = a_Settings.GetValueSet("Worlds", "DefaultWorld", "world");
	m_pDefaultWorld = new cWorld(DefaultWorldName.c_str());
	m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;

	// Then load the other worlds
	auto Worlds = a_Settings.GetValues("Worlds");
	if (Worlds.size() <= 0)
	{
		return;
	}

	bool FoundAdditionalWorlds = false;
	for (auto WorldNameValue : Worlds)
	{
		AString ValueName = WorldNameValue.first;
		if (ValueName.compare("World") != 0)
		{
			continue;
		}
		AString WorldName = WorldNameValue.second;
		if (WorldName.empty())
		{
			continue;
		}
		FoundAdditionalWorlds = true;
		cWorld * NewWorld = new cWorld(WorldName.c_str());
		m_WorldsByName[WorldName] = NewWorld;
	}  // for i - Worlds

	if (!FoundAdditionalWorlds)
	{
		if (a_Settings.GetKeyComment("Worlds", 0) != " World=secondworld")
		{
			a_Settings.DeleteKeyComment("Worlds", 0);
			a_Settings.AddKeyComment("Worlds", " World=secondworld");
		}
	}
}
Ejemplo n.º 3
0
void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIniFile)
{
	if (a_IsNewIniFile)
	{
		a_Settings.AddValue("Worlds", "DefaultWorld", "world");
		a_Settings.AddValue("Worlds", "World", "world_nether");
		a_Settings.AddValue("Worlds", "World", "world_end");
		m_pDefaultWorld = new cWorld("world");
		m_WorldsByName["world"] = m_pDefaultWorld;
		m_WorldsByName["world_nether"] = new cWorld("world_nether", dimNether, "world");
		m_WorldsByName["world_end"] = new cWorld("world_end", dimEnd, "world");
		return;
	}

	// First get the default world
	AString DefaultWorldName = a_Settings.GetValueSet("Worlds", "DefaultWorld", "world");
	m_pDefaultWorld = new cWorld(DefaultWorldName.c_str());
	m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
	auto Worlds = a_Settings.GetValues("Worlds");

	// Fix servers that have default world configs created prior to #2815. See #2810.
	// This can probably be removed several years after 2016
	// We start by inspecting the world linkage and determining if it's the default one
	if ((DefaultWorldName == "world") && (Worlds.size() == 1))
	{
		auto DefaultWorldIniFile= cpp14::make_unique<cIniFile>();
		if (DefaultWorldIniFile->ReadFile("world/world.ini"))
		{
			AString NetherName = DefaultWorldIniFile->GetValue("LinkedWorlds", "NetherWorldName", "");
			AString EndName = DefaultWorldIniFile->GetValue("LinkedWorlds", "EndWorldName", "");
			if ((NetherName.compare("world_nether") == 0) && (EndName.compare("world_end") == 0))
			{
				// This is a default world linkage config, see if the nether and end are in settings.ini
				// If both of them are not in settings.ini, then this is a pre-#2815 default config
				// so we add them to settings.ini
				// Note that if only one of them is not in settings.ini, it's nondefault and we don't touch it

				bool NetherInSettings = false;
				bool EndInSettings = false;

				for (auto WorldNameValue : Worlds)
				{
					AString ValueName = WorldNameValue.first;
					if (ValueName.compare("World") != 0)
					{
						continue;
					}
					AString WorldName = WorldNameValue.second;
					if (WorldName.compare("world_nether") == 0)
					{
						NetherInSettings = true;
					}
					else if (WorldName.compare("world_end") == 0)
					{
						EndInSettings = true;
					}
				}

				if ((!NetherInSettings) && (!EndInSettings))
				{
					a_Settings.AddValue("Worlds", "World", "world_nether");
					a_Settings.AddValue("Worlds", "World", "world_end");
					Worlds = a_Settings.GetValues("Worlds");  // Refresh the Worlds list so that the rest of the function works as usual
					LOG("The server detected an old default config with bad world linkages. This has been autofixed by adding \"world_nether\" and \"world_end\" to settings.ini");
				}
			}
		}
	}

	// Then load the other worlds
	if (Worlds.size() <= 0)
	{
		return;
	}

	/* Here are the world creation rules. Note that these only apply for a world which is in settings.ini but has no world.ini file.
	If an ini file is present, it overrides the world linkages and the dimension type in cWorld::start()
	The creation rules are as follows:

	- If a world exists in settings.ini but has no world.ini, then:
		- If the world name is x_nether, create a world.ini with the dimension type "nether".
			- If a world called x exists, set it as x_nether's overworld.
			- Otherwise set the default world as x_nether's overworld.

		- If the world name is x_end, create a world.ini with the dimension type "end".
			- If a world called x exists, set it as x_end's overworld.
			- Otherwise set the default world as x_end's overworld.

		- If the world name is x (and doesn't end with _end or _nether)
			- Create a world.ini with a dimension type of "overworld".
			- If a world called x_nether exists, set it as x's nether world.
			- Otherwise set x's nether world to blank.h
			- If a world called x_end  exists, set it as x's end world.
			- Otherwise set x's nether world to blank.

	*/

	bool FoundAdditionalWorlds = false;
	for (auto WorldNameValue : Worlds)
	{
		AString ValueName = WorldNameValue.first;
		if (ValueName.compare("World") != 0)
		{
			continue;
		}
		AString WorldName = WorldNameValue.second;
		if (WorldName.empty())
		{
			continue;
		}
		FoundAdditionalWorlds = true;
		cWorld * NewWorld;
		AString LowercaseName = StrToLower(WorldName);
		AString NetherAppend="_nether";
		AString EndAppend="_end";

		// if the world is called x_nether
		if ((LowercaseName.size() > NetherAppend.size()) && (LowercaseName.substr(LowercaseName.size() - NetherAppend.size()) == NetherAppend))
		{
			// The world is called x_nether, see if a world called x exists. If yes, choose it as the linked world,
			// otherwise, choose the default world as the linked world.
			// As before, any ini settings will completely override this if an ini is already present.

			AString LinkTo = WorldName.substr(0, WorldName.size() - NetherAppend.size());
			if (GetWorld(LinkTo) == nullptr)
			{
				LinkTo = DefaultWorldName;
			}
			NewWorld = new cWorld(WorldName.c_str(), dimNether, LinkTo);
		}
		// if the world is called x_end
		else if ((LowercaseName.size() > EndAppend.size()) && (LowercaseName.substr(LowercaseName.size() - EndAppend.size()) == EndAppend))
		{
			// The world is called x_end, see if a world called x exists. If yes, choose it as the linked world,
			// otherwise, choose the default world as the linked world.
			// As before, any ini settings will completely override this if an ini is already present.

			AString LinkTo = WorldName.substr(0, WorldName.size() - EndAppend.size());
			if (GetWorld(LinkTo) == nullptr)
			{
				LinkTo = DefaultWorldName;
			}
			NewWorld = new cWorld(WorldName.c_str(), dimEnd, LinkTo);
		}
		else
		{
			NewWorld = new cWorld(WorldName.c_str());
		}
		m_WorldsByName[WorldName] = NewWorld;
	}  // for i - Worlds

	if (!FoundAdditionalWorlds)
	{
		if (a_Settings.GetKeyComment("Worlds", 0) != " World=secondworld")
		{
			a_Settings.DeleteKeyComment("Worlds", 0);
			a_Settings.AddKeyComment("Worlds", " World=secondworld");
		}
	}
}
Ejemplo n.º 4
0
void cRoot::LoadWorlds(cSettingsRepositoryInterface & a_Settings, bool a_IsNewIniFile)
{
	if (a_IsNewIniFile)
	{
		a_Settings.AddValue("Worlds", "DefaultWorld", "world");
		a_Settings.AddValue("Worlds", "World", "world_nether");
		a_Settings.AddValue("Worlds", "World", "world_end");
		m_pDefaultWorld = new cWorld("world");
		m_WorldsByName["world"] = m_pDefaultWorld;
		m_WorldsByName["world_nether"] = new cWorld("world_nether", dimNether, "world");
		m_WorldsByName["world_end"] = new cWorld("world_end", dimEnd, "world");
		return;
	}

	// First get the default world
	AString DefaultWorldName = a_Settings.GetValueSet("Worlds", "DefaultWorld", "world");
	m_pDefaultWorld = new cWorld(DefaultWorldName.c_str());
	m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld;
	auto Worlds = a_Settings.GetValues("Worlds");

	// Then load the other worlds
	if (Worlds.size() <= 0)
	{
		return;
	}

	/* Here are the world creation rules. Note that these only apply for a world which is in settings.ini but has no world.ini file.
	If an ini file is present, it overrides the world linkages and the dimension type in cWorld::start()
	The creation rules are as follows:

	- If a world exists in settings.ini but has no world.ini, then:
		- If the world name is x_nether, create a world.ini with the dimension type "nether".
			- If a world called x exists, set it as x_nether's overworld.
			- Otherwise set the default world as x_nether's overworld.

		- If the world name is x_end, create a world.ini with the dimension type "end".
			- If a world called x exists, set it as x_end's overworld.
			- Otherwise set the default world as x_end's overworld.

		- If the world name is x (and doesn't end with _end or _nether)
			- Create a world.ini with a dimension type of "overworld".
			- If a world called x_nether exists, set it as x's nether world.
			- Otherwise set x's nether world to blank.h
			- If a world called x_end  exists, set it as x's end world.
			- Otherwise set x's nether world to blank.

	*/

	bool FoundAdditionalWorlds = false;
	for (auto WorldNameValue : Worlds)
	{
		AString ValueName = WorldNameValue.first;
		if (ValueName.compare("World") != 0)
		{
			continue;
		}
		AString WorldName = WorldNameValue.second;
		if (WorldName.empty())
		{
			continue;
		}
		FoundAdditionalWorlds = true;
		cWorld * NewWorld;
		AString LowercaseName = StrToLower(WorldName);
		AString NetherAppend="_nether";
		AString EndAppend="_end";

		// if the world is called x_nether
		if ((LowercaseName.size() > NetherAppend.size()) && (LowercaseName.substr(LowercaseName.size() - NetherAppend.size()) == NetherAppend))
		{
			// The world is called x_nether, see if a world called x exists. If yes, choose it as the linked world,
			// otherwise, choose the default world as the linked world.
			// As before, any ini settings will completely override this if an ini is already present.

			AString LinkTo = WorldName.substr(0, WorldName.size() - NetherAppend.size());
			if (GetWorld(LinkTo) == nullptr)
			{
				LinkTo = DefaultWorldName;
			}
			NewWorld = new cWorld(WorldName.c_str(), dimNether, LinkTo);
		}
		// if the world is called x_end
		else if ((LowercaseName.size() > EndAppend.size()) && (LowercaseName.substr(LowercaseName.size() - EndAppend.size()) == EndAppend))
		{
			// The world is called x_end, see if a world called x exists. If yes, choose it as the linked world,
			// otherwise, choose the default world as the linked world.
			// As before, any ini settings will completely override this if an ini is already present.

			AString LinkTo = WorldName.substr(0, WorldName.size() - EndAppend.size());
			if (GetWorld(LinkTo) == nullptr)
			{
				LinkTo = DefaultWorldName;
			}
			NewWorld = new cWorld(WorldName.c_str(), dimEnd, LinkTo);
		}
		else
		{
			NewWorld = new cWorld(WorldName.c_str());
		}
		m_WorldsByName[WorldName] = NewWorld;
	}  // for i - Worlds

	if (!FoundAdditionalWorlds)
	{
		if (a_Settings.GetKeyComment("Worlds", 0) != " World=secondworld")
		{
			a_Settings.DeleteKeyComment("Worlds", 0);
			a_Settings.AddKeyComment("Worlds", " World=secondworld");
		}
	}
}