Search in sources :

Example 1 with LanternAdvancement

use of org.lanternpowered.server.advancement.LanternAdvancement in project LanternServer by LanternPowered.

the class LanternTreeLayout method generateNode.

private static TreeNode generateNode(Advancement advancement, TreeLayoutElement element, int column) {
    final TreeNode treeNode = new TreeNode(element, (double) column * HORIZONTAL_OFFSET);
    TreeNode previous = null;
    for (Advancement child : advancement.getChildren()) {
        final TreeLayoutElement childElement = ((LanternAdvancement) child).getLayoutElement();
        if (childElement != null) {
            final TreeNode childNode = generateNode(child, childElement, column + 1);
            childNode.previous = previous;
            childNode.parent = treeNode;
            if (previous != null) {
                previous.next = childNode;
            }
            treeNode.children.add(childNode);
            previous = childNode;
        }
    }
    return treeNode;
}
Also used : TreeLayoutElement(org.spongepowered.api.advancement.TreeLayoutElement) LanternAdvancement(org.lanternpowered.server.advancement.LanternAdvancement) LanternAdvancement(org.lanternpowered.server.advancement.LanternAdvancement) Advancement(org.spongepowered.api.advancement.Advancement)

Aggregations

LanternAdvancement (org.lanternpowered.server.advancement.LanternAdvancement)1 Advancement (org.spongepowered.api.advancement.Advancement)1 TreeLayoutElement (org.spongepowered.api.advancement.TreeLayoutElement)1