Search in sources :

Example 1 with AdvancementTree

use of org.spongepowered.api.advancement.AdvancementTree in project LanternServer by LanternPowered.

the class LanternPlayerAdvancements method getUnlockedAdvancementTrees.

public Collection<AdvancementTree> getUnlockedAdvancementTrees() {
    final ImmutableList.Builder<AdvancementTree> builder = ImmutableList.builder();
    for (AdvancementTree tree : AdvancementTreeRegistryModule.get().getAll()) {
        final Advancement advancement = tree.getRootAdvancement();
        final LanternAdvancementProgress progress = get(advancement);
        if ((!progress.dirtyVisibility && progress.visible) || (progress.dirtyVisibility && shouldBeVisible(advancement))) {
            builder.add(tree);
        }
    }
    return builder.build();
}
Also used : AdvancementTree(org.spongepowered.api.advancement.AdvancementTree) ImmutableList(com.google.common.collect.ImmutableList) Advancement(org.spongepowered.api.advancement.Advancement)

Example 2 with AdvancementTree

use of org.spongepowered.api.advancement.AdvancementTree in project LanternServer by LanternPowered.

the class AdvancementTreeLayoutModule method registerDefaults.

@DelayedRegistration(RegistrationPhase.INIT)
@Override
public void registerDefaults() {
    for (AdvancementTree tree : AdvancementTreeRegistryModule.get().getAll()) {
        final LanternTreeLayout layout = new LanternTreeLayout(tree);
        layout.generate();
    }
}
Also used : AdvancementTree(org.spongepowered.api.advancement.AdvancementTree) LanternTreeLayout(org.lanternpowered.server.advancement.layout.LanternTreeLayout) DelayedRegistration(org.spongepowered.api.registry.util.DelayedRegistration)

Example 3 with AdvancementTree

use of org.spongepowered.api.advancement.AdvancementTree in project SpongeCommon by SpongePowered.

the class MixinAdvancementTreeNode method onLayout.

@Inject(method = "layout", at = @At("RETURN"))
private static void onLayout(Advancement root, CallbackInfo ci) {
    final AdvancementTree advancementTree = ((org.spongepowered.api.advancement.Advancement) root).getTree().get();
    final TreeLayout layout = new SpongeTreeLayout((SpongeAdvancementTree) advancementTree);
    SpongeImpl.postEvent(SpongeEventFactory.createAdvancementTreeEventGenerateLayout(Sponge.getCauseStackManager().getCurrentCause(), layout, advancementTree));
}
Also used : SpongeTreeLayout(org.spongepowered.common.advancement.SpongeTreeLayout) SpongeAdvancementTree(org.spongepowered.common.advancement.SpongeAdvancementTree) AdvancementTree(org.spongepowered.api.advancement.AdvancementTree) SpongeTreeLayout(org.spongepowered.common.advancement.SpongeTreeLayout) TreeLayout(org.spongepowered.api.advancement.TreeLayout) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with AdvancementTree

use of org.spongepowered.api.advancement.AdvancementTree in project LanternServer by LanternPowered.

the class LanternPlayer method registerKeys.

@Override
public void registerKeys() {
    super.registerKeys();
    final ValueCollection c = getValueCollection();
    ((ElementKeyRegistration<?, Optional<AdvancementTree>>) c.get(LanternKeys.OPEN_ADVANCEMENT_TREE).get()).addListener((oldElement, newElement) -> {
        if (getWorld() != null) {
            this.session.send(new MessagePlayOutSelectAdvancementTree(newElement.map(AdvancementTree::getId).orElse(null)));
        }
    });
}
Also used : AdvancementTree(org.spongepowered.api.advancement.AdvancementTree) MessagePlayOutSelectAdvancementTree(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSelectAdvancementTree) MessagePlayOutSelectAdvancementTree(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSelectAdvancementTree) ValueCollection(org.lanternpowered.server.data.ValueCollection) ElementKeyRegistration(org.lanternpowered.server.data.element.ElementKeyRegistration)

Aggregations

AdvancementTree (org.spongepowered.api.advancement.AdvancementTree)4 ImmutableList (com.google.common.collect.ImmutableList)1 LanternTreeLayout (org.lanternpowered.server.advancement.layout.LanternTreeLayout)1 ValueCollection (org.lanternpowered.server.data.ValueCollection)1 ElementKeyRegistration (org.lanternpowered.server.data.element.ElementKeyRegistration)1 MessagePlayOutSelectAdvancementTree (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSelectAdvancementTree)1 Advancement (org.spongepowered.api.advancement.Advancement)1 TreeLayout (org.spongepowered.api.advancement.TreeLayout)1 DelayedRegistration (org.spongepowered.api.registry.util.DelayedRegistration)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 SpongeAdvancementTree (org.spongepowered.common.advancement.SpongeAdvancementTree)1 SpongeTreeLayout (org.spongepowered.common.advancement.SpongeTreeLayout)1