From 525ea1552b2e01d608cf10cf0b76be662862c188 Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 6 Dec 2016 21:12:13 +1100 Subject: SPIGOT-1592: Implement ItemMeta for Spawn Eggs The Minecraft implementation of spawn eggs is able to construct an entity using all data that is present in the save format, however since the Bukkit API has no such way to construct an entity unattached to a world, and it appears creating such a way is a very challenging task, the decision was instead made to add this API now that 1.11 has entities which may not be represented by data values. In the future it may be possible to implement a more expanded API cognate with this one. --- .../org/bukkit/inventory/meta/SpawnEggMeta.java | 28 ++++++++++++++++++++++ src/main/java/org/bukkit/material/SpawnEgg.java | 8 ++++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java (limited to 'src/main/java') diff --git a/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java b/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java new file mode 100644 index 00000000..b89802d1 --- /dev/null +++ b/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java @@ -0,0 +1,28 @@ +package org.bukkit.inventory.meta; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +/** + * Represents a {@link Material#MONSTER_EGG} and it's spawned type. + */ +public interface SpawnEggMeta extends ItemMeta { + + /** + * Get the type of entity this egg will spawn. + * + * @return The entity type. May be null for implementation specific default. + */ + EntityType getSpawnedType(); + + /** + * Set the type of entity this egg will spawn. + * + * @param type The entity type. May be null for implementation specific + * default. + */ + void setSpawnedType(EntityType type); + + @Override + SpawnEggMeta clone(); +} diff --git a/src/main/java/org/bukkit/material/SpawnEgg.java b/src/main/java/org/bukkit/material/SpawnEgg.java index 596d08ae..40be534a 100644 --- a/src/main/java/org/bukkit/material/SpawnEgg.java +++ b/src/main/java/org/bukkit/material/SpawnEgg.java @@ -2,11 +2,13 @@ package org.bukkit.material; import org.bukkit.Material; import org.bukkit.entity.EntityType; -import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.SpawnEggMeta; /** * Represents a spawn egg that can be used to spawn mobs + * @deprecated use {@link SpawnEggMeta} */ +@Deprecated public class SpawnEgg extends MaterialData { public SpawnEgg() { @@ -41,7 +43,7 @@ public class SpawnEgg extends MaterialData { * Get the type of entity this egg will spawn. * * @return The entity type. - * @deprecated This is now stored in {@link ItemMeta}. See SPIGOT-1592. + * @deprecated This is now stored in {@link SpawnEggMeta}. */ @Deprecated public EntityType getSpawnedType() { @@ -52,7 +54,7 @@ public class SpawnEgg extends MaterialData { * Set the type of entity this egg will spawn. * * @param type The entity type. - * @deprecated This is now stored in {@link ItemMeta}. See SPIGOT-1592. + * @deprecated This is now stored in {@link SpawnEggMeta}. */ @Deprecated public void setSpawnedType(EntityType type) { -- cgit v1.2.3