Skip to content

Commit

Permalink
Remove zombie-specific profession from VillagerProfession
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Aug 19, 2016
1 parent 73854b8 commit d9f31ff
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main/src/main/java/net/citizensnpcs/trait/VillagerProfession.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ public VillagerProfession() {
public void load(DataKey key) throws NPCLoadException {
try {
profession = Profession.valueOf(key.getString(""));
if (profession == Profession.NORMAL) {
profession = Profession.FARMER;
}
} catch (IllegalArgumentException ex) {
throw new NPCLoadException("Invalid profession.");
}
}

@Override
public void onSpawn() {
if (npc.getEntity() instanceof Villager)
if (npc.getEntity() instanceof Villager) {
((Villager) npc.getEntity()).setProfession(profession);
}
}

@Override
Expand All @@ -37,9 +41,13 @@ public void save(DataKey key) {
}

public void setProfession(Profession profession) {
if (profession == Profession.NORMAL) {
profession = Profession.FARMER;
}
this.profession = profession;
if (npc.getEntity() instanceof Villager)
if (npc.getEntity() instanceof Villager) {
((Villager) npc.getEntity()).setProfession(profession);
}
}

@Override
Expand Down

0 comments on commit d9f31ff

Please sign in to comment.