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

The following examples show how to use ninja.leaping.configurate.ConfigurationNode#isVirtual() . 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: AbstractConfigurateStorage.java    From LuckPerms with MIT License 6 votes vote down vote up
private static ImmutableContextSet readContexts(ConfigurationNode attributes) {
    ImmutableContextSet.Builder contextBuilder = new ImmutableContextSetImpl.BuilderImpl();
    ConfigurationNode contextMap = attributes.getNode("context");
    if (!contextMap.isVirtual() && contextMap.hasMapChildren()) {
        contextBuilder.addAll(ContextSetConfigurateSerializer.deserializeContextSet(contextMap));
    }

    String server = attributes.getNode("server").getString("global");
    if (!server.equals("global")) {
        contextBuilder.add(DefaultContextKeys.SERVER_KEY, server);
    }

    String world = attributes.getNode("world").getString("global");
    if (!world.equals("global")) {
        contextBuilder.add(DefaultContextKeys.WORLD_KEY, world);
    }

    return contextBuilder.build();
}
 
Example 2
Source File: Configuration.java    From Prism with MIT License 6 votes vote down vote up
public void loadConfiguration() {
    try {
        ConfigurationNode configurationNode = getConfigurationLoader().load();

        if (!configurationNode.isVirtual() && configurationNode.getNode("general", "schema-version").isVirtual()) {
            Prism.getInstance().getLogger().info("Converting Configuration...");
            convertConfiguration(configurationNode);
        } else {
            getObjectMapper().populate(configurationNode);
        }

        Prism.getInstance().getLogger().info("Successfully loaded configuration file.");
    } catch (Exception ex) {
        Prism.getInstance().getLogger().error("Encountered an error while loading config", ex);
    }
}
 
Example 3
Source File: BlockModelResource.java    From BlueMap with MIT License 5 votes vote down vote up
private Element buildElement(BlockModelResource model, ConfigurationNode node, String topModelPath) throws ParseResourceException {
	Element element = model.new Element();
	
	element.from = readVector3f(node.getNode("from"));
	element.to = readVector3f(node.getNode("to"));
	
	element.shade = node.getNode("shade").getBoolean(true);
	
	boolean fullElement = element.from.equals(FULL_CUBE_FROM) && element.to.equals(FULL_CUBE_TO);
	
	if (!node.getNode("rotation").isVirtual()) {
		element.rotation.angle = node.getNode("rotation", "angle").getFloat(0);
		element.rotation.axis = Axis.fromString(node.getNode("rotation", "axis").getString("x"));
		if (!node.getNode("rotation", "origin").isVirtual()) element.rotation.origin = readVector3f(node.getNode("rotation", "origin"));
		element.rotation.rescale = node.getNode("rotation", "rescale").getBoolean(false);
	}
	
	boolean allDirs = true;
	for (Direction direction : Direction.values()) {
		ConfigurationNode faceNode = node.getNode("faces", direction.name().toLowerCase());
		if (!faceNode.isVirtual()) {
			try {
				Face face = buildFace(element, direction, faceNode);
				element.faces.put(direction, face);
			} catch (ParseResourceException | IOException ex) {
				Logger.global.logDebug("Failed to parse an " + direction + " face for the model " + topModelPath + "! " + ex);
			}
		} else {
			allDirs = false;
		}
	}
	
	if (fullElement && allDirs) element.fullCube = true;
	
	return element;
}
 
Example 4
Source File: FeatureManager.java    From ChatUI with MIT License 5 votes vote down vote up
private ConfigurationNode featureConfig(String featureId) {
    ConfigurationNode config = Config.getRootNode().getNode("features", featureId, "config");
    if (config.isVirtual()) {
        config.setValue(Collections.emptyMap());
    }
    return config;
}
 
Example 5
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 6
Source File: ConfigurateConfigAdapter.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public List<String> getStringList(String path, List<String> def) {
    ConfigurationNode node = resolvePath(path);
    if (node.isVirtual() || !node.hasListChildren()) {
        return def;
    }

    return node.getList(Object::toString);
}
 
Example 7
Source File: ConfigurateConfigAdapter.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public List<String> getKeys(String path, List<String> def) {
    ConfigurationNode node = resolvePath(path);
    if (node.isVirtual() || !node.hasMapChildren()) {
        return def;
    }

    return node.getChildrenMap().keySet().stream().map(Object::toString).collect(Collectors.toList());
}
 
Example 8
Source File: ConfigurateConfigAdapter.java    From LuckPerms with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Map<String, String> getStringMap(String path, Map<String, String> def) {
    ConfigurationNode node = resolvePath(path);
    if (node.isVirtual()) {
        return def;
    }

    Map<String, Object> m = (Map<String, Object>) node.getValue(Collections.emptyMap());
    return m.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, v -> v.getValue().toString()));
}
 
Example 9
Source File: MainConfig.java    From BlueMap with MIT License 4 votes vote down vote up
private void assertNotPresent(ConfigurationNode node) throws OutdatedConfigException {
	if (!node.isVirtual()) throw new OutdatedConfigException("Configurtion-node '" + ConfigUtils.nodePathToString(node) + "' is no longer used, please update your configuration!");
}
 
Example 10
Source File: CombinedConfigurateStorage.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
protected ConfigurationNode readFile(StorageLocation location, String name) throws IOException {
    ConfigurationNode root = getStorageLoader(location).getNode();
    ConfigurationNode node = root.getNode(name);
    return node.isVirtual() ? null : node;
}