SPIGOT-5647: ZombieVillager entity should have getVillagerType()

This commit is contained in:
md_5 2020-03-30 12:15:21 +11:00
parent 4d975ac3b7
commit 95bd4238fb

View file

@ -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();