From 337955e3aaa71021164f5fef3ad5f2f9af8bb62c Mon Sep 17 00:00:00 2001 From: ShaneBee Date: Sun, 9 Feb 2020 10:47:09 +1100 Subject: [PATCH] SPIGOT-5468: Improve Beehive TileEntity API --- src/main/java/org/bukkit/block/Beehive.java | 10 +++- .../org/bukkit/block/EntityBlockStorage.java | 56 +++++++++++++++++++ src/main/java/org/bukkit/entity/Bee.java | 14 +++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/bukkit/block/EntityBlockStorage.java diff --git a/src/main/java/org/bukkit/block/Beehive.java b/src/main/java/org/bukkit/block/Beehive.java index c1c47c24..655fd0b5 100644 --- a/src/main/java/org/bukkit/block/Beehive.java +++ b/src/main/java/org/bukkit/block/Beehive.java @@ -1,12 +1,13 @@ package org.bukkit.block; import org.bukkit.Location; +import org.bukkit.entity.Bee; import org.jetbrains.annotations.Nullable; /** * Represents a captured state of a bee hive. */ -public interface Beehive extends TileState { +public interface Beehive extends EntityBlockStorage { /** * Get the hive's flower location. @@ -22,4 +23,11 @@ public interface Beehive extends TileState { * @param location or null */ void setFlower(@Nullable Location location); + + /** + * Check if the hive is sedated due to smoke from a nearby campfire. + * + * @return True if hive is sedated + */ + boolean isSedated(); } diff --git a/src/main/java/org/bukkit/block/EntityBlockStorage.java b/src/main/java/org/bukkit/block/EntityBlockStorage.java new file mode 100644 index 00000000..f3f8d765 --- /dev/null +++ b/src/main/java/org/bukkit/block/EntityBlockStorage.java @@ -0,0 +1,56 @@ +package org.bukkit.block; + +import java.util.List; +import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a captured state of a block which stores entities. + * + * @param Entity this block can store + */ +public interface EntityBlockStorage extends TileState { + + /** + * Check if the block is completely full of entities. + * + * @return True if block is full + */ + boolean isFull(); + + /** + * Get the amount of entities currently in this block. + * + * @return Amount of entities currently in this block + */ + int getEntityCount(); + + /** + * Get the maximum amount of entities this block can hold. + * + * @return Maximum amount of entities this block can hold + */ + int getMaxEntities(); + + /** + * Set the maximum amount of entities this block can hold. + * + * @param max Maximum amount of entities this block can hold + */ + void setMaxEntities(int max); + + /** + * Release all the entities currently stored in the block. + * + * @return List of all entities which were released + */ + @NotNull + List releaseEntities(); + + /** + * Add an entity to the block. + * + * @param entity Entity to add to the block + */ + void addEntity(@NotNull T entity); +} diff --git a/src/main/java/org/bukkit/entity/Bee.java b/src/main/java/org/bukkit/entity/Bee.java index 41b23d87..adb20a9a 100644 --- a/src/main/java/org/bukkit/entity/Bee.java +++ b/src/main/java/org/bukkit/entity/Bee.java @@ -79,4 +79,18 @@ public interface Bee extends Animals { * @param anger new anger */ void setAnger(int anger); + + /** + * Get the amount of ticks the bee cannot enter the hive for. + * + * @return Ticks the bee cannot enter a hive for + */ + int getCannotEnterHiveTicks(); + + /** + * Set the amount of ticks the bee cannot enter a hive for. + * + * @param ticks Ticks the bee cannot enter a hive for + */ + void setCannotEnterHiveTicks(int ticks); }