From 52a4fa93bb500c7101a82fce74bcf5e8c231fbc2 Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Sun, 14 Jun 2020 13:24:45 +0200 Subject: [PATCH] fixed my way to detect if a player could sleep or not, now using BedEnterResult to know if the player is actually in the bed --- src/main/java/xyz/louisvallat/sweetdreams/SweetDreams.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/xyz/louisvallat/sweetdreams/SweetDreams.java b/src/main/java/xyz/louisvallat/sweetdreams/SweetDreams.java index 4f753c9..3e6efe7 100644 --- a/src/main/java/xyz/louisvallat/sweetdreams/SweetDreams.java +++ b/src/main/java/xyz/louisvallat/sweetdreams/SweetDreams.java @@ -35,9 +35,7 @@ public final class SweetDreams extends JavaPlugin implements Listener { public void onSleep(PlayerBedEnterEvent event) { final Player player = event.getPlayer(); final World world = player.getWorld(); - if (world.isThundering() || - (world.getTime() >= 12541 && world.getTime() <= 23458)) // https://minecraft.gamepedia.com/Bed#Sleeping - { + if (event.getBedEnterResult() == PlayerBedEnterEvent.BedEnterResult.OK) { sleepingSchedulers.put(player, this.getServer().getScheduler().scheduleSyncDelayedTask(this, () -> { if (world.isThundering()) world.setThundering(false); else world.setTime(1000);