ignoring player sleeping when going to bed, and not ignoring it anymore when they wake up
This commit is contained in:
parent
52a4fa93bb
commit
0c6261973c
@ -36,6 +36,7 @@ public final class SweetDreams extends JavaPlugin implements Listener {
|
||||
final Player player = event.getPlayer();
|
||||
final World world = player.getWorld();
|
||||
if (event.getBedEnterResult() == PlayerBedEnterEvent.BedEnterResult.OK) {
|
||||
player.setSleepingIgnored(true);
|
||||
sleepingSchedulers.put(player, this.getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||
if (world.isThundering()) world.setThundering(false);
|
||||
else world.setTime(1000);
|
||||
@ -48,5 +49,6 @@ public final class SweetDreams extends JavaPlugin implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onWake(PlayerBedLeaveEvent event) {
|
||||
this.getServer().getScheduler().cancelTask(sleepingSchedulers.get(event.getPlayer()));
|
||||
event.getPlayer().setSleepingIgnored(false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user