From 95bd4238fb5e3dbced75f95935e48736b6ca14bc Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 30 Mar 2020 12:15:21 +1100 Subject: [PATCH] SPIGOT-5647: ZombieVillager entity should have getVillagerType() --- .../craftbukkit/entity/CraftVillagerZombie.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index 4776354442..2c8f157a92 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -11,6 +11,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.EntityType; import org.bukkit.entity.Villager; import org.bukkit.entity.ZombieVillager; @@ -47,6 +48,17 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { getHandle().setVillagerData(getHandle().getVillagerData().withProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT))))); } + @Override + public Villager.Type getVillagerType() { + return Villager.Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getKey().toUpperCase(Locale.ROOT)); + } + + @Override + public void setVillagerType(Villager.Type type) { + Validate.notNull(type); + getHandle().setVillagerData(getHandle().getVillagerData().withType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())))); + } + @Override public boolean isConverting() { return getHandle().isConverting();