@Override public Hostage getHostage(Entity entity) { Hostage h; try { h = (Hostage) ((CraftEntity) entity).getHandle(); } catch (ClassCastException ex) { // Caused by baby villager or a non-Hostage Villager. plugin .debug() .log( "onHostageInteract() ClassCastException: most likely " + "caused by a baby villager or a Villager that is not a Hostage."); Villager v = (Villager) entity; World world = ((CraftWorld) v.getWorld()).getHandle(); CraftHostage hostage = new CraftHostage(world, v.getProfession().getId()); hostage.setLocation(v.getLocation()); world.removeEntity(((CraftEntity) entity).getHandle()); world.addEntity(hostage); hostage.setHealth((float) v.getHealth()); hostage.setProfessionType(v.getProfession()); hostage.setCustomName(v.getCustomName()); return hostage; } return h; }