use of org.spongepowered.common.interfaces.advancement.IMixinICriterionTriggerListener in project SpongeCommon by SpongePowered.
the class SpongeTrigger method trigger.
@Override
public void trigger(Player player) {
final PlayerAdvancements playerAdvancements = ((EntityPlayerMP) player).getAdvancements();
final Cause cause = Sponge.getCauseStackManager().getCurrentCause();
final TypeToken typeToken = TypeToken.of(this.triggerConfigurationClass);
for (Listener listener : new ArrayList<>(this.listeners.get(playerAdvancements))) {
final IMixinICriterionTriggerListener mixinListener = (IMixinICriterionTriggerListener) listener;
final Advancement advancement = (Advancement) mixinListener.getAdvancement();
final AdvancementCriterion advancementCriterion = (AdvancementCriterion) ((net.minecraft.advancements.Advancement) advancement).getCriteria().get(mixinListener.getCriterionName());
final CriterionEvent.Trigger event = SpongeEventFactory.createCriterionEventTrigger(cause, advancement, advancementCriterion, typeToken, player, (FilteredTrigger) listener.getCriterionInstance(), this.eventHandler == null);
if (this.eventHandler != null) {
this.eventHandler.accept(event);
if (!event.getResult()) {
continue;
}
}
SpongeImpl.postEvent(event);
if (event.getResult()) {
listener.grantCriterion(playerAdvancements);
}
}
}
Aggregations