From 7befec442068fe1cba4443b3e34bb8e2746f4b89 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Mon, 11 May 2020 00:19:04 -0400 Subject: [PATCH] Potential bed api (#3339) --- .../0206-Potential-bed-API.patch | 32 +++++++++++++++++++ .../0514-Potential-bed-API.patch | 31 ++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 Spigot-API-Patches/0206-Potential-bed-API.patch create mode 100644 Spigot-Server-Patches/0514-Potential-bed-API.patch diff --git a/Spigot-API-Patches/0206-Potential-bed-API.patch b/Spigot-API-Patches/0206-Potential-bed-API.patch new file mode 100644 index 000000000..764a63d9d --- /dev/null +++ b/Spigot-API-Patches/0206-Potential-bed-API.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: JRoy +Date: Sun, 10 May 2020 23:06:41 -0400 +Subject: [PATCH] Potential bed API + +Adds a new method to fetch the location of a player's bed without generating any sync loads. + +getPotentialBedLocation - Gets the last known location of a player's bed. This does not preform any check if the bed is still valid and does not load any chunks. + +diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java +index 79569a329aa19ed954b9b65b78ef5d6d313501a1..c0d38f5a39610cbc523d210b76f17fa17c0d7e62 100644 +--- a/src/main/java/org/bukkit/entity/HumanEntity.java ++++ b/src/main/java/org/bukkit/entity/HumanEntity.java +@@ -248,6 +248,18 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder + @Nullable + public Location getBedSpawnLocation(); + ++ // Paper start - Potential bed api ++ /** ++ * Gets the Location of the player's bed, null if they have not slept ++ * in one. This method will not attempt to validate if the current bed ++ * is still valid. ++ * ++ * @return Bed Location if has slept in one, otherwise null. ++ */ ++ @Nullable ++ public Location getPotentialBedLocation(); ++ // Paper end ++ + /** + * Sets the Location where the player will spawn at their bed. + * diff --git a/Spigot-Server-Patches/0514-Potential-bed-API.patch b/Spigot-Server-Patches/0514-Potential-bed-API.patch new file mode 100644 index 000000000..2dd156300 --- /dev/null +++ b/Spigot-Server-Patches/0514-Potential-bed-API.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: JRoy +Date: Sun, 10 May 2020 23:06:30 -0400 +Subject: [PATCH] Potential bed API + +Adds a new method to fetch the location of a player's bed without generating any sync loads. + +getPotentialBedLocation - Gets the last known location of a player's bed. This does not preform any check if the bed is still valid and does not load any chunks. + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +index a5e9fc90ffae794b9b14468337ce7b091fd0dc35..a2815073bc04dd831fa22da47162031d360683dd 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +@@ -143,6 +143,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { + return null; + } + ++ // Paper start - Potential bed api ++ @Override ++ public Location getPotentialBedLocation() { ++ BlockPosition bed = getHandle().getBed(); ++ if (bed == null) { ++ return null; ++ } ++ return new Location(getServer().getWorld(getHandle().spawnWorld), bed.getX(), bed.getY(), bed.getZ()); ++ } ++ // Paper end ++ + @Override + public void setBedSpawnLocation(Location location) { + setBedSpawnLocation(location, false);