Skip to content

Commit

Permalink
( Patch for #1509 ) support zombie villagers in the villager professi…
Browse files Browse the repository at this point in the history
…on trait (#1510)
  • Loading branch information
Serializator authored and fullwall committed Jun 7, 2018
1 parent ce9332b commit 4ae8a19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ public void power(CommandContext args, CommandSender sender, NPC npc) {
min = 2,
max = 2,
permission = "citizens.npc.profession")
@Requirements(selected = true, ownership = true, types = { EntityType.VILLAGER })
@Requirements(selected = true, ownership = true, types = { EntityType.VILLAGER, EntityType.ZOMBIE_VILLAGER })
public void profession(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
String profession = args.getString(1);
Profession parsed = Util.matchEnum(Profession.values(), profession.toUpperCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.api.util.DataKey;
import org.bukkit.entity.ZombieVillager;

@TraitName("profession")
public class VillagerProfession extends Trait {
Expand All @@ -32,6 +33,8 @@ public void load(DataKey key) throws NPCLoadException {
public void onSpawn() {
if (npc.getEntity() instanceof Villager) {
((Villager) npc.getEntity()).setProfession(profession);
} else if (npc.getEntity() instanceof ZombieVillager) {
((ZombieVillager) npc.getEntity()).setVillagerProfession(profession);
}
}

Expand All @@ -47,6 +50,8 @@ public void setProfession(Profession profession) {
this.profession = profession;
if (npc.getEntity() instanceof Villager) {
((Villager) npc.getEntity()).setProfession(profession);
} else if (npc.getEntity() instanceof ZombieVillager) {
((ZombieVillager) npc.getEntity()).setVillagerProfession(profession);
}
}

Expand Down

0 comments on commit 4ae8a19

Please sign in to comment.