From 152b372feb4e459f1ad8808fda69a9fc74407db6 Mon Sep 17 00:00:00 2001 From: Carsten Gips Date: Mon, 1 Jul 2024 15:30:00 +0200 Subject: [PATCH] Dungeon: do not throw exceptions in stream operations (refactoring, SpikeSystem) see https://github.com/Dungeon-CampusMinden/Dungeon/pull/1564#discussion_r1660926970 --- dungeon/src/contrib/systems/SpikeSystem.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dungeon/src/contrib/systems/SpikeSystem.java b/dungeon/src/contrib/systems/SpikeSystem.java index 999096a507..da5ef8e885 100644 --- a/dungeon/src/contrib/systems/SpikeSystem.java +++ b/dungeon/src/contrib/systems/SpikeSystem.java @@ -20,6 +20,7 @@ public SpikeSystem() { @Override public void execute() { filteredEntityStream(SpikyComponent.class) - .forEach(e -> e.fetch(SpikyComponent.class).orElseThrow().reduceCoolDown()); + .flatMap((e -> e.fetch(SpikyComponent.class).stream())) + .forEach(sc -> sc.reduceCoolDown()); } }