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);
}