From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 3 Jul 2021 16:57:27 -0500
Subject: [PATCH] SPIGOT-5988 Fix bed respawn location not resetting


diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 1b61cc59a120261dbf178865471a7ee2620977f1..9770a8b7ce0b27c0cb9851ac942b3089a053dc7b 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -903,6 +903,7 @@ public abstract class PlayerList {
                     location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
                 } else if (blockposition != null) {
                     entityplayer1.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
+                    if (net.pl3x.purpur.PurpurConfig.fixBedRespawns) entityplayer1.setRespawnPosition(worldserver1.dimension(), null, 0.0F, false, false); // Purpur - fix SPIGOT-5988
                 }
             }
 
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
index 97dba790a02fe54da4278c7e913dbbcf8a25d126..60412d24201bbd61162662b3a2270eecab39fa3d 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -407,6 +407,7 @@ public class PurpurConfig {
     public static int beeInsideBeeHive = 3;
     public static boolean anvilCumulativeCost = true;
     public static int lightningRodRange = 128;
+    public static boolean fixBedRespawns = false;
     private static void blockSettings() {
         if (version < 3) {
             boolean oldValue = getBoolean("settings.barrel.packed-barrels", true);
@@ -425,6 +426,7 @@ public class PurpurConfig {
         beeInsideBeeHive = getInt("settings.blocks.beehive.max-bees-inside", beeInsideBeeHive);
         anvilCumulativeCost = getBoolean("settings.blocks.anvil.cumulative-cost", anvilCumulativeCost);
         lightningRodRange = getInt("settings.blocks.lightning_rod.range", lightningRodRange);
+        fixBedRespawns = getBoolean("settings.blocks.bed.fix-spigot-5988", fixBedRespawns);
     }
 
     public static boolean allowInfinityMending = false;
