From c987938a6a8f595cd71e5e8974c28e13db0c4b0b Mon Sep 17 00:00:00 2001 From: LelouBil Date: Mon, 22 Jul 2019 00:00:36 +0200 Subject: [PATCH] SPIGOT-5180: Add Villager#sleep() and #wakeup() methods --- src/main/java/org/bukkit/entity/Villager.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/org/bukkit/entity/Villager.java b/src/main/java/org/bukkit/entity/Villager.java index 0b96d1a0..ef48ad9b 100644 --- a/src/main/java/org/bukkit/entity/Villager.java +++ b/src/main/java/org/bukkit/entity/Villager.java @@ -2,6 +2,7 @@ package org.bukkit.entity; import java.util.Locale; import org.bukkit.Keyed; +import org.bukkit.Location; import org.bukkit.NamespacedKey; import org.jetbrains.annotations.NotNull; @@ -76,6 +77,25 @@ public interface Villager extends AbstractVillager { */ public void setVillagerExperience(int experience); + /** + * Attempts to make this villager sleep at the given location. + *
+ * The location must be in the current world and have a bed placed at the + * location. The villager will put its head on the specified block while + * sleeping. + * + * @param location the location of the bed + * @return whether the sleep was successful + */ + public boolean sleep(@NotNull Location location); + + /** + * Causes this villager to wake up if he's currently sleeping. + * + * @throws IllegalStateException if not sleeping + */ + public void wakeup(); + /** * Represents Villager type, usually corresponding to what biome they spawn * in.