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();
}
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();
}
}
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));
}
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)));
}
});
}
Aggregations