Skip to content

Commit

Permalink
Use streams rather than optional
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Dec 13, 2024
1 parent f90ebcc commit 7535f96
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import javax.annotation.Nullable;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;

@Getter
public abstract class LivingEntity extends Entity {
Expand Down Expand Up @@ -623,8 +624,7 @@ public void jumpFromGround() {
protected void pushEntities() {
this.level().getEntities(this.getBoundingBox())
.stream()
.<Optional<Player>>map(e -> e instanceof Player player ? Optional.of(player) : Optional.empty())
.flatMap(Optional::stream)
.flatMap(e -> e instanceof Player player ? Stream.of(player) : Stream.empty())
.filter(Predicate.not(Entity::isSpectator))
.filter(Entity::isPushable)
.filter(Player::isLocalPlayer)
Expand Down

0 comments on commit 7535f96

Please sign in to comment.