diff --git a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 741a39e0e..63e33b3eb 100644 --- a/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/main/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -30,6 +30,7 @@ import org.bukkit.entity.Ocelot; import org.bukkit.entity.Player; import org.bukkit.entity.Rabbit; import org.bukkit.entity.Villager.Profession; +import org.bukkit.entity.Zombie; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import com.google.common.base.Joiner; @@ -114,8 +115,8 @@ public class NPCCommands { max = 2, permission = "citizens.npc.age") public void age(CommandContext args, CommandSender sender, NPC npc) throws CommandException { - if (!npc.isSpawned() || !(npc.getEntity() instanceof Ageable)) - throw new CommandException(Messages.MOBTYPE_CANNOT_BE_AGED); + if (!npc.isSpawned() || (!(npc.getEntity() instanceof Ageable) && !(npc.getEntity() instanceof Zombie))) + throw new CommandException(Messages.MOBTYPE_CANNOT_BE_AGED, npc.getName()); Age trait = npc.getTrait(Age.class); boolean toggleLock = args.hasFlag('l'); diff --git a/main/src/main/java/net/citizensnpcs/trait/Age.java b/main/src/main/java/net/citizensnpcs/trait/Age.java index 85ac11f05..d4991ed5c 100644 --- a/main/src/main/java/net/citizensnpcs/trait/Age.java +++ b/main/src/main/java/net/citizensnpcs/trait/Age.java @@ -2,6 +2,7 @@ package net.citizensnpcs.trait; import org.bukkit.command.CommandSender; import org.bukkit.entity.Ageable; +import org.bukkit.entity.Zombie; import net.citizensnpcs.api.persistence.Persist; import net.citizensnpcs.api.trait.Trait; @@ -36,8 +37,12 @@ public class Age extends Trait implements Toggleable { entity.setAge(age); entity.setAgeLock(locked); ageable = entity; - } else + } else if (npc.getEntity() instanceof Zombie) { + ((Zombie) npc.getEntity()).setBaby(age < 0); ageable = null; + } else { + ageable = null; + } } @Override @@ -51,14 +56,17 @@ public class Age extends Trait implements Toggleable { this.age = age; if (isAgeable()) { ageable.setAge(age); + } else if (npc.getEntity() instanceof Zombie) { + ((Zombie) npc.getEntity()).setBaby(age < 0); } } @Override public boolean toggle() { locked = !locked; - if (isAgeable()) + if (isAgeable()) { ageable.setAgeLock(locked); + } return locked; }