From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Mon, 8 Mar 2021 16:46:54 -0500
Subject: [PATCH] Config to ignore nearby mobs when sleeping


diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index e081a02d6799d8d74db06ca84e224c395e95a308..26fcead85fe017a27d41697cbf7b6d1da16c8879 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1307,7 +1307,7 @@ public class ServerPlayer extends Player {
                             return entitymonster.isPreventingPlayerRest((Player) this);
                         });
 
-                        if (!list.isEmpty()) {
+                        if (!this.level.purpurConfig.playerSleepNearMonsters && !list.isEmpty()) { // Purpur
                             return Either.left(Player.BedSleepingProblem.NOT_SAFE);
                         }
                     }
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 44ffdbe9fa16ab111e2f598a47ba54194d4d94dd..39496742ed05737029e67592755cd74331e1cb95 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -310,6 +310,7 @@ public class PurpurWorldConfig {
     public boolean totemOfUndyingWorksInInventory = false;
     public boolean playerFixStuckPortal = false;
     public boolean creativeOnePunch = false;
+    public boolean playerSleepNearMonsters = false;
     private void playerSettings() {
         idleTimeoutKick = getBoolean("gameplay-mechanics.player.idle-timeout.kick-if-idle", idleTimeoutKick);
         idleTimeoutTickNearbyEntities = getBoolean("gameplay-mechanics.player.idle-timeout.tick-nearby-entities", idleTimeoutTickNearbyEntities);
@@ -324,6 +325,7 @@ public class PurpurWorldConfig {
         totemOfUndyingWorksInInventory = getBoolean("gameplay-mechanics.player.totem-of-undying-works-in-inventory", totemOfUndyingWorksInInventory);
         playerFixStuckPortal = getBoolean("gameplay-mechanics.player.fix-stuck-in-portal", playerFixStuckPortal);
         creativeOnePunch = getBoolean("gameplay-mechanics.player.one-punch-in-creative", creativeOnePunch);
+        playerSleepNearMonsters = getBoolean("gameplay-mechanics.player.sleep-ignore-nearby-mobs", playerSleepNearMonsters);
     }
 
     public int snowballDamage = -1;
