Não sei muito mais vou tentar ajudar
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player)sender;
if (label.equalsIgnoreCase("mn")) {
if (p.hasPermission("cmd")) {
Villager v = (Villager)p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
v.setCustomName("§5testre");
v.setCustomNameVisible(true);
v.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 9999999, 99999999));
v.setProfession(Villager.Profession.LIBRARIAN);
@EventHandler
public void onNPCDamage(EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof Villager && e.getDamager() instanceof Player) {
e.setCancelled(true);
}
}