Search in sources :

Example 1 with ElementKeyRegistration

use of org.lanternpowered.server.data.element.ElementKeyRegistration 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

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 AdvancementTree (org.spongepowered.api.advancement.AdvancementTree)1