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

The following examples show how to use ninja.leaping.configurate.ConfigurationNode#getChildrenList() . 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: ConfigUtils.java    From BlueMap with MIT License 6 votes vote down vote up
public static Vector3i readVector3i(ConfigurationNode vectorNode){
	if (vectorNode.hasListChildren()){
		List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
		return new Vector3i(
				list.get(0).getInt(),
				list.get(1).getInt(),
				list.get(2).getInt()
			);
	}
	
	return new Vector3i(
			vectorNode.getNode("x").getInt(),
			vectorNode.getNode("y").getInt(),
			vectorNode.getNode("z").getInt()
		);
}
 
Example 2
Source File: ConfigUtils.java    From BlueMap with MIT License 6 votes vote down vote up
public static Vector3f readVector3f(ConfigurationNode vectorNode){
	if (vectorNode.hasListChildren()){
		List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
		return new Vector3f(
				list.get(0).getFloat(),
				list.get(1).getFloat(),
				list.get(2).getFloat()
			);
	}
	
	return new Vector3f(
			vectorNode.getNode("x").getFloat(),
			vectorNode.getNode("y").getFloat(),
			vectorNode.getNode("z").getFloat()
		);
}
 
Example 3
Source File: ConfigUtils.java    From BlueMap with MIT License 6 votes vote down vote up
public static Vector4i readVector4i(ConfigurationNode vectorNode){
	if (vectorNode.hasListChildren()){
		List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
		return new Vector4i(
				list.get(0).getInt(),
				list.get(1).getInt(),
				list.get(2).getInt(),
				list.get(3).getInt()
			);
	}
	
	return new Vector4i(
			vectorNode.getNode("x").getInt(),
			vectorNode.getNode("y").getInt(),
			vectorNode.getNode("z").getInt(),
			vectorNode.getNode("w").getInt()
		);
}
 
Example 4
Source File: ConfigUtils.java    From BlueMap with MIT License 6 votes vote down vote up
public static Vector4f readVector4f(ConfigurationNode vectorNode){
	if (vectorNode.hasListChildren()){
		List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
		return new Vector4f(
				list.get(0).getFloat(),
				list.get(1).getFloat(),
				list.get(2).getFloat(),
				list.get(3).getFloat()
			);
	}
	
	return new Vector4f(
			vectorNode.getNode("x").getFloat(),
			vectorNode.getNode("y").getFloat(),
			vectorNode.getNode("z").getFloat(),
			vectorNode.getNode("w").getFloat()
		);
}
 
Example 5
Source File: ContextSetConfigurateSerializer.java    From LuckPerms with MIT License 6 votes vote down vote up
public static ContextSet deserializeContextSet(ConfigurationNode data) {
    Preconditions.checkArgument(data.hasMapChildren());
    Map<Object, ? extends ConfigurationNode> dataMap = data.getChildrenMap();

    if (dataMap.isEmpty()) {
        return ImmutableContextSetImpl.EMPTY;
    }

    MutableContextSet map = new MutableContextSetImpl();
    for (Map.Entry<Object, ? extends ConfigurationNode> e : dataMap.entrySet()) {
        String k = e.getKey().toString();
        ConfigurationNode v = e.getValue();

        if (v.hasListChildren()) {
            List<? extends ConfigurationNode> values = v.getChildrenList();
            for (ConfigurationNode value : values) {
                map.add(k, value.getString());
            }
        } else {
            map.add(k, v.getString());
        }
    }

    return map;
}
 
Example 6
Source File: BlockModelResource.java    From BlueMap with MIT License 5 votes vote down vote up
private Vector3f readVector3f(ConfigurationNode node) throws ParseResourceException {
	List<? extends ConfigurationNode> nodeList = node.getChildrenList();
	if (nodeList.size() < 3) throw new ParseResourceException("Failed to load Vector3: Not enough values in list-node!");
	
	return new Vector3f(
			nodeList.get(0).getFloat(0),
			nodeList.get(1).getFloat(0),
			nodeList.get(2).getFloat(0)
		);
}
 
Example 7
Source File: BlockModelResource.java    From BlueMap with MIT License 5 votes vote down vote up
private Vector4f readVector4f(ConfigurationNode node) throws ParseResourceException {
	List<? extends ConfigurationNode> nodeList = node.getChildrenList();
	if (nodeList.size() < 4) throw new ParseResourceException("Failed to load Vector4: Not enough values in list-node!");
	
	return new Vector4f(
			nodeList.get(0).getFloat(0),
			nodeList.get(1).getFloat(0),
			nodeList.get(2).getFloat(0),
			nodeList.get(3).getFloat(0)
		);
}
 
Example 8
Source File: ConfigUtils.java    From BlueMap with MIT License 5 votes vote down vote up
public static Vector2i readVector2i(ConfigurationNode vectorNode){
	if (vectorNode.hasListChildren()){
		List<? extends ConfigurationNode> list = vectorNode.getChildrenList();
		return new Vector2i(
				list.get(0).getInt(),
				list.get(1).getInt()
			);
	}
	
	return new Vector2i(
			vectorNode.getNode("x").getInt(),
			vectorNode.getNode("y").getInt()
		);
}
 
Example 9
Source File: ShapeMarkerImpl.java    From BlueMap with MIT License 5 votes vote down vote up
private Shape readShape(ConfigurationNode node) throws MarkerFileFormatException {
	List<? extends ConfigurationNode> posNodes = node.getChildrenList();
	
	if (posNodes.size() < 3) throw new MarkerFileFormatException("Failed to read shape: point-list has fewer than 3 entries!");
	
	Vector2d[] positions = new Vector2d[posNodes.size()];
	for (int i = 0; i < positions.length; i++) {
		positions[i] = readShapePos(posNodes.get(i));
	}
	
	return new Shape(positions);
}
 
Example 10
Source File: GsonTypeSerializer.java    From helper with MIT License 5 votes vote down vote up
@Override
public JsonElement deserialize(TypeToken<?> type, ConfigurationNode from) throws ObjectMappingException {
    if (from.getValue() == null) {
        return JsonNull.INSTANCE;
    }

    if (from.hasListChildren()) {
        List<? extends ConfigurationNode> childrenList = from.getChildrenList();
        JsonArray array = new JsonArray();
        for (ConfigurationNode node : childrenList) {
            array.add(node.getValue(TYPE));
        }
        return array;
    }

    if (from.hasMapChildren()) {
        Map<Object, ? extends ConfigurationNode> childrenMap = from.getChildrenMap();
        JsonObject object = new JsonObject();
        for (Map.Entry<Object, ? extends ConfigurationNode> ent : childrenMap.entrySet()) {
            object.add(ent.getKey().toString(), ent.getValue().getValue(TYPE));
        }
        return object;
    }

    Object val = from.getValue();
    try {
        return GsonConverters.IMMUTABLE.wrap(val);
    } catch (IllegalArgumentException e) {
        throw new ObjectMappingException(e);
    }
}
 
Example 11
Source File: ClaimSetTypeSerializer.java    From EagleFactions with MIT License 5 votes vote down vote up
@Override
public Set<Claim> deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException
{
    final Set<Claim> claims = new HashSet<>();
    final List<? extends ConfigurationNode> nodes = value.getChildrenList();
    for (final ConfigurationNode configurationNode : nodes)
    {
        final Claim claim = configurationNode.getValue(EFTypeSerializers.CLAIM_TYPE_TOKEN);
        if (claim != null)
            claims.add(claim);
    }
    return claims;
}
 
Example 12
Source File: MainConfig.java    From BlueMap with MIT License 4 votes vote down vote up
private void loadMapConfigs(ConfigurationNode node) throws IOException {
	mapConfigs = new ArrayList<>();
	for (ConfigurationNode mapConfigNode : node.getChildrenList()) {
		mapConfigs.add(new MapConfig(mapConfigNode));
	}
}