Java Code Examples for ninja.leaping.configurate.ConfigurationNode#getBoolean()

The following examples show how to use ninja.leaping.configurate.ConfigurationNode#getBoolean() . 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: ActivePlayerChatView.java    From ChatUI with MIT License 6 votes vote down vote up
public void onConfigChange(ConfigurationNode node, PlayerSettings playerConfig, ConfigurationNode config) {
    if (node.getKey().equals("width")) {
        LibConfig.updatePlayer(playerConfig.withWidth(node.getInt()), getPlayer());
    } else if (node.getKey().equals("height")) {
        LibConfig.updatePlayer(playerConfig.withHeight(node.getInt()), getPlayer());
    } else if (node.getKey().equals("unicode")) {
        LibConfig.updatePlayer(playerConfig.withUnicode(node.getBoolean()), getPlayer());
    } else if (node.getKey().equals("font")) {
        LibConfig.updatePlayer(playerConfig.withFontData(node.getString()), getPlayer());
    } else if (node.getKey().equals("enabled")) {
        config.getNode("enabled").setValue(node.getValue());
        if (!node.getBoolean()) {
            disable();
        }
    }
}
 
Example 2
Source File: FeatureManager.java    From ChatUI with MIT License 5 votes vote down vote up
private boolean canLoad(String featureId) {
    ConfigurationNode enabled = Config.getRootNode().getNode("features", featureId, "enabled");
    if (enabled.isVirtual()) {
        enabled.setValue(true);
    }
    return enabled.getBoolean(true);
}
 
Example 3
Source File: SecurityService.java    From Web-API with MIT License 5 votes vote down vote up
/**
 * Returns a permissions tree representing the passed configuration node
 * @param config The configuration node which represents a permission set
 * @return A tree structure representing the config node
 */
public static TreeNode permissionTreeFromConfig(ConfigurationNode config) {
    if (config == null || config.getValue() == null) {
        return new TreeNode(false);
    }

    if (!config.hasMapChildren()) {
        if (config.getValue().getClass() == Boolean.class)
            return new TreeNode(config.getKey().toString(), config.getBoolean());
        else {
            TreeNode node = new TreeNode(config.getKey().toString(), true);
            node.addChild(new TreeNode("*", true));
            return node;
        }
    }

    TreeNode root = new TreeNode(config.getKey().toString(), true);
    for (Map.Entry<Object, ? extends ConfigurationNode> entry : config.getChildrenMap().entrySet()) {
        if (entry.getKey().toString().equalsIgnoreCase(".")) {
            root.setValue(entry.getValue().getBoolean());
            continue;
        }

        root.addChild(permissionTreeFromConfig(entry.getValue()));
    }
    return root;
}
 
Example 4
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static boolean getAFKKick()
{
	ConfigurationNode valueNode = Configs.getConfig(mainConfig).getNode((Object[]) ("afk.kick.use").split("\\."));

	if (valueNode.getValue() != null)
	{
		return valueNode.getBoolean();
	}
	else
	{
		Utils.setAFKKick(false);
		return false;
	}
}
 
Example 5
Source File: Utils.java    From EssentialCmds with MIT License 5 votes vote down vote up
public static boolean shouldAnnounceAFK()
{
	ConfigurationNode valueNode = Configs.getConfig(mainConfig).getNode((Object[]) ("afk.announce").split("\\."));

	if (valueNode.getValue() != null)
	{
		return valueNode.getBoolean();
	}
	else
	{
		Configs.setValue(mainConfig, valueNode.getPath(), true);
		return true;
	}
}