SPIGOT-4560: Add HumanEntity.sleep and related APIs

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2019-01-02 14:37:43 +11:00
parent 6a8d62ff22
commit e943059623
2 changed files with 55 additions and 24 deletions

View file

@ -221,6 +221,61 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder
*/
public int getSleepTicks();
/**
* Gets the Location where the player will spawn at their bed, null if
* they have not slept in one or their current bed spawn is invalid.
*
* @return Bed Spawn Location if bed exists, otherwise null.
*/
public Location getBedSpawnLocation();
/**
* Sets the Location where the player will spawn at their bed.
*
* @param location where to set the respawn location
*/
public void setBedSpawnLocation(Location location);
/**
* Sets the Location where the player will spawn at their bed.
*
* @param location where to set the respawn location
* @param force whether to forcefully set the respawn location even if a
* valid bed is not present
*/
public void setBedSpawnLocation(Location location, boolean force);
/**
* Attempts to make the entity sleep at the given location.
* <br>
* The location must be in the current world and have a bed placed at the
* location. The game may also enforce other requirements such as proximity
* to bed, monsters, and dimension type if force is not set.
*
* @param location the location of the bed
* @param force whether to try and sleep at the location even if not
* normally possible
* @return whether the sleep was successful
*/
public boolean sleep(Location location, boolean force);
/**
* Causes the player to wakeup if they are currently sleeping.
*
* @param setSpawnLocation whether to set their spawn location to the bed
* they are currently sleeping in
* @throws IllegalStateException if not sleeping
*/
public void wakeup(boolean setSpawnLocation);
/**
* Gets the location of the bed the player is currently sleeping in
*
* @return location
* @throws IllegalStateException if not sleeping
*/
public Location getBedLocation();
/**
* Gets this human's current {@link GameMode}
*

View file

@ -887,30 +887,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
*/
public void setFoodLevel(int value);
/**
* Gets the Location where the player will spawn at their bed, null if
* they have not slept in one or their current bed spawn is invalid.
*
* @return Bed Spawn Location if bed exists, otherwise null.
*/
public Location getBedSpawnLocation();
/**
* Sets the Location where the player will spawn at their bed.
*
* @param location where to set the respawn location
*/
public void setBedSpawnLocation(Location location);
/**
* Sets the Location where the player will spawn at their bed.
*
* @param location where to set the respawn location
* @param force whether to forcefully set the respawn location even if a
* valid bed is not present
*/
public void setBedSpawnLocation(Location location, boolean force);
/**
* Determines if the Player is allowed to fly via jump key double-tap like
* in creative mode.