Paper/Spigot-Server-Patches/0515-Potential-bed-API.patch
Aikar f0409edcd7
Drop Close region files patch, doesn't add any value.
Upon further knowledge of the system, it is known that region files
are closing properly, as well as this didn't help native memory use anyways.

This patch also caused issues compiling on a newer JDK being able to
release the jar to java 8 users.
2020-06-08 17:07:23 -04:00

32 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JRoy <joshroy126@gmail.com>
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);