Java Code Examples for ninja.leaping.configurate.commented.CommentedConfigurationNode#getString()

The following examples show how to use ninja.leaping.configurate.commented.CommentedConfigurationNode#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From EssentialCmds with MIT License 6 votes vote down vote up
public static Text getFirstJoinMsg(String playerName)
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("message", "firstjoin");
	String message;

	if (configManager.getString(node).isPresent())
	{
		message = node.getString();
	}
	else
	{
		setFirstJoinMsg("&4Welcome &a@p &4to the server!");
		message = "&4Welcome &a@p &4to the server!";
	}

	message = message.replaceAll("@p", playerName);

	if ((message.contains("https://")) || (message.contains("http://")))
	{
		return Utils.getURL(message);
	}

	return TextSerializers.FORMATTING_CODE.deserialize(message);
}
 
Example 2
Source File: Utils.java    From EssentialCmds with MIT License 6 votes vote down vote up
public static void addRule(String rule)
{
	CommentedConfigurationNode node = Configs.getConfig(rulesConfig).getNode("rules", "rules");
	String formattedItem = (rule + ",");

	if (configManager.getString(node).isPresent())
	{
		String items = node.getString();

		if (!items.contains(formattedItem))
			Configs.setValue(rulesConfig, node.getPath(), items + formattedItem);
		return;
	}

	Configs.setValue(rulesConfig, node.getPath(), formattedItem);
}
 
Example 3
Source File: ConfigHandler.java    From Nations with MIT License 5 votes vote down vote up
public static void ensureString(CommentedConfigurationNode node, String def)
{
	if (node.getString() == null)
	{
		node.setValue(def);
	}
}
 
Example 4
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static String getMySQLPort()
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("mysql", "port");
	if (configManager.getString(node).isPresent())
		return node.getString();
	setSQLPort("8080");
	return "8080";
}
 
Example 5
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static String getMySQLDatabase()
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("mysql", "database");
	if (configManager.getString(node).isPresent())
		return node.getString();
	setSQLDatabase("Mutes");
	return "Mutes";
}
 
Example 6
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static String getMySQLPassword()
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("mysql", "password");
	if (configManager.getString(node).isPresent())
		return node.getString();
	setSQLPass("cat");
	return "cat";
}
 
Example 7
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static String getMySQLUsername()
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("mysql", "username");
	if (configManager.getString(node).isPresent())
		return node.getString();
	setSQLUsername("HassanS6000");
	return "HassanS6000";
}
 
Example 8
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static String getMySQLHost()
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("mysql", "host");
	if (configManager.getString(node).isPresent())
		return node.getString();
	setSQLHost("");
	return "";
}
 
Example 9
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static Text getLoginMessage(String playerName)
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("message", "login");
	String message;

	if (configManager.getString(node).isPresent())
	{
		message = node.getString();
	}
	else
	{
		setLoginMessage("");
		message = "";
	}

	if (message.isEmpty())
	{
		return Text.EMPTY;
	}

	message = message.replaceAll("@p", playerName);

	if ((message.contains("https://")) || (message.contains("http://")))
	{
		return Utils.getURL(message);
	}

	return TextSerializers.FORMATTING_CODE.deserialize(message);
}
 
Example 10
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static String getDisconnectMessage()
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("message", "disconnect");
	if (configManager.getString(node).isPresent())
		return node.getString();
	setDisconnectMessage("");
	return "";
}
 
Example 11
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static String getNick(Player player)
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("nick", player.getUniqueId().toString());
	if (configManager.getString(node).isPresent())
		return node.getString();
	else
		return player.getName();
}
 
Example 12
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static void removeRule(int ruleIndex)
{
	CommentedConfigurationNode node = Configs.getConfig(rulesConfig).getNode("rules", "rules");
	String ruleToRemove = getRules().get(ruleIndex);

	if (configManager.getString(node).isPresent() && ruleToRemove != null)
	{
		String items = node.getString();
		Configs.setValue(rulesConfig, node.getPath(), items.replace(ruleToRemove + ",", ""));
	}
}
 
Example 13
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static void addBlacklistItem(String itemId)
{
	CommentedConfigurationNode node = Configs.getConfig(mainConfig).getNode("essentialcmds", "items", "blacklist");
	String formattedItem = (itemId + ",");

	if (configManager.getString(node).isPresent())
	{
		String items = node.getString();
		Configs.setValue(mainConfig, node.getPath(), items + formattedItem);
		return;
	}

	Configs.setValue(mainConfig, node.getPath(), formattedItem);
}