From 941fdacbc500c2372b3364908d4328a0d26a9f26 Mon Sep 17 00:00:00 2001 From: MrGeneralQ Date: Thu, 1 Sep 2022 11:58:26 +0200 Subject: [PATCH] hotfix for players not being registered --- pom.xml | 2 +- .../mrgeneralq/sleepmost/services/InsomniaService.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b9a78f5..af6d973 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 me.mrgeneralq sleep-most - 5.1.0 + 5.1.1 SleepMost diff --git a/src/main/java/me/mrgeneralq/sleepmost/services/InsomniaService.java b/src/main/java/me/mrgeneralq/sleepmost/services/InsomniaService.java index 8d55386..14de585 100644 --- a/src/main/java/me/mrgeneralq/sleepmost/services/InsomniaService.java +++ b/src/main/java/me/mrgeneralq/sleepmost/services/InsomniaService.java @@ -2,9 +2,12 @@ import me.mrgeneralq.sleepmost.interfaces.IInsomniaService; import me.mrgeneralq.sleepmost.interfaces.ISleepMostPlayerService; +import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.entity.Player; +import java.util.stream.Collectors; + public class InsomniaService implements IInsomniaService { private final ISleepMostPlayerService sleepMostPlayerService; @@ -26,12 +29,16 @@ public void enableInsomnia(World world) { @Override public void disableInsomnia(Player player, World world) { + + if(!player.isOnline()) + return; + this.sleepMostPlayerService.getPlayer(player).setInsomniaStatus(world, false); } @Override public void disableInsomnia(World world) { - for(Player p: world.getPlayers()) + for(Player p: world.getPlayers().stream().filter(OfflinePlayer::isOnline).collect(Collectors.toList())) this.disableInsomnia(p, world); }