From 518e458c5fbc5dc51613731cc6e3d0e8ae8fd298 Mon Sep 17 00:00:00 2001 From: punchready Date: Wed, 7 Jul 2021 15:00:12 +0200 Subject: [PATCH] fix: add additional protection to stone cooldown check --- .../marvelous/gamelibrary/gamelogic/StoneCooldownManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/StoneCooldownManager.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/StoneCooldownManager.java index 51f46a6..a14c82b 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/StoneCooldownManager.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/gamelogic/StoneCooldownManager.java @@ -41,7 +41,7 @@ public class StoneCooldownManager { * Decreases all cooldowns by one according to a round having passed. */ public void update() { - cooldowns.replaceAll((s, v) -> Math.max(0, cooldowns.get(s) - 1)); + cooldowns.replaceAll((s, v) -> Math.max(0, cooldowns.getOrDefault(s, 0) - 1)); } /** @@ -67,7 +67,7 @@ public class StoneCooldownManager { * @param stone The {@link StoneType} to mark */ public void setCooldown(StoneType stone) { - cooldowns.put(stone, Math.max(0, maxCooldowns.get(stone))); + cooldowns.put(stone, Math.max(0, maxCooldowns.getOrDefault(stone, 0))); } /**