Skip to content

Commit

Permalink
simplify.
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Sep 30, 2024
1 parent eec0ec1 commit d5ba743
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package net.infumia.frame.pipeline.service.view;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import net.infumia.frame.context.view.ContextClick;
import net.infumia.frame.element.Element;
import net.infumia.frame.element.ElementRich;
import net.infumia.frame.pipeline.PipelineServiceConsumer;
import net.infumia.frame.pipeline.Pipelined;
Expand All @@ -29,14 +26,13 @@ public String key() {
public CompletableFuture<State> handle(@NotNull final PipelineContextView.Click ctx) {
final ContextClick context = ctx.context();
final int clickedSlot = context.clickedSlotRaw();
final List<Element> elements = context.elements();
final Optional<ElementRich> found = elements
return context
.elements()
.stream()
.map(ElementRich.class::cast)
.filter(ElementRich::visible)
.filter(e -> e.containedWithin(clickedSlot))
.findFirst();
return found
.findFirst()
.map(Pipelined::pipelines)
.map(pipelines -> pipelines.executeClick(context))
.orElseGet(() -> CompletableFuture.completedFuture(State.CONTINUE));
Expand Down

0 comments on commit d5ba743

Please sign in to comment.