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
This commit is contained in:
parent
ec2a01b129
commit
52a4fa93bb
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user