From ce28be83ad9199ab591c50ac5a07f73046995e42 Mon Sep 17 00:00:00 2001 From: Mykyta Komarnytskyy Date: Tue, 10 Nov 2020 10:33:51 -0800 Subject: [PATCH] Fix #70 This fixes the thunderstorm looping bug by forcing players out of bed immediately and only removing the world from the skipping queue after 20 ticks. --- .../nkomarn/harbor/task/AccelerateNightTask.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/xyz/nkomarn/harbor/task/AccelerateNightTask.java b/src/main/java/xyz/nkomarn/harbor/task/AccelerateNightTask.java index f9d824d..38c44e0 100644 --- a/src/main/java/xyz/nkomarn/harbor/task/AccelerateNightTask.java +++ b/src/main/java/xyz/nkomarn/harbor/task/AccelerateNightTask.java @@ -3,6 +3,7 @@ package xyz.nkomarn.harbor.task; import org.bukkit.Bukkit; import org.bukkit.Statistic; import org.bukkit.World; +import org.bukkit.entity.LivingEntity; import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; import xyz.nkomarn.harbor.Harbor; @@ -53,9 +54,15 @@ public class AccelerateNightTask extends BukkitRunnable { world.getPlayers().forEach(player -> player.setStatistic(Statistic.TIME_SINCE_REST, 0)); } - checker.resetStatus(world); - harbor.getPlayerManager().clearCooldowns(); - harbor.getMessages().sendRandomChatMessage(world, "messages.chat.night-skipped"); + world.getPlayers().stream() + .filter(LivingEntity::isSleeping) + .forEach(player -> player.wakeup(true)); + + harbor.getServer().getScheduler().runTaskLater(harbor, () -> { + checker.resetStatus(world); + harbor.getPlayerManager().clearCooldowns(); + harbor.getMessages().sendRandomChatMessage(world, "messages.chat.night-skipped"); + }, 20L); cancel(); return; }