Skip to content

Commit

Permalink
Add STRAY and HUSK support in theory, for #1453
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jul 15, 2016
1 parent c88b2f6 commit f711026
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Expand Up @@ -59,6 +59,8 @@ public void setInfected(boolean bool) {
}
}

// TODO: Should be bother allowing villager input at all?

// If it's a Villager, we need to spawn a Zombie instead.
// This is kind of messy, and can be improved upon.
// TODO: Improve upon.
Expand Down
Expand Up @@ -9,6 +9,7 @@
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;

public class EntityProfession implements Property {

Expand All @@ -17,8 +18,8 @@ public static boolean describes(dObject entity) {
if (!(entity instanceof dEntity)) {
return false;
}
// Check if the entity is a Villager, the only EntityType that can be a Professional
return ((dEntity) entity).getBukkitEntityType() == EntityType.VILLAGER;
return ((dEntity) entity).getBukkitEntityType() == EntityType.VILLAGER
|| ((dEntity) entity).getBukkitEntityType() == EntityType.ZOMBIE;
}

public static EntityProfession getFrom(dObject entity) {
Expand All @@ -43,11 +44,19 @@ private EntityProfession(dEntity entity) {
dEntity professional;

private Villager.Profession getProfession() {
if (professional.getBukkitEntityType() == EntityType.ZOMBIE) {
return ((Zombie) professional.getBukkitEntity()).getVillagerProfession();
}
return ((Villager) professional.getBukkitEntity()).getProfession();
}

public void setProfession(Villager.Profession profession) {
((Villager) professional.getBukkitEntity()).setProfession(profession);
if (professional.getBukkitEntityType() == EntityType.ZOMBIE) {
((Zombie) professional.getBukkitEntity()).setVillagerProfession(profession);
}
else {
((Villager) professional.getBukkitEntity()).setProfession(profession);
}
}


Expand All @@ -57,6 +66,9 @@ public void setProfession(Villager.Profession profession) {

@Override
public String getPropertyString() {
if (professional.getBukkitEntityType() == EntityType.ZOMBIE && !((Zombie) professional.getBukkitEntity()).isVillager()) {
return null;
}
return CoreUtilities.toLowerCase(getProfession().name());
}

Expand Down Expand Up @@ -84,8 +96,8 @@ public String getAttribute(Attribute attribute) {
// @group properties
// @description
// If the entity can have professions, returns the entity's profession.
// Currently, only Villager-type entities can have professions.
// Possible professions: BLACKSMITH, BUTCHER, FARMER, LIBRARIAN, PRIEST.
// Currently, only Villager-type and infected zombie entities can have professions.
// Possible professions: BLACKSMITH, BUTCHER, FARMER, LIBRARIAN, PRIEST. (Or HUSK for zombies!)
// -->
if (attribute.startsWith("profession")) {
return new Element(CoreUtilities.toLowerCase(getProfession().name()))
Expand All @@ -105,7 +117,7 @@ public void adjust(Mechanism mechanism) {
// @description
// Changes the entity's profession.
// Currently, only Villager-type entities can have professions.
// Acceptable professions: BLACKSMITH, BUTCHER, FARMER, LIBRARIAN, PRIEST.
// Acceptable professions: BLACKSMITH, BUTCHER, FARMER, LIBRARIAN, PRIEST. (Or HUSK for zombies!)
// @tags
// <e@entity.profession>
// -->
Expand Down
Expand Up @@ -67,7 +67,7 @@ public String getAttribute(Attribute attribute) {
// @group properties
// @description
// If the entity is a skeleton, returns what type of skeleton it is.
// Can return NORMAL or WITHER.
// Can return: NORMAL, WITHER, STRAY.
// -->
if (attribute.startsWith("skeleton_type")) {
return new Element(((Skeleton) skeleton.getBukkitEntity())
Expand All @@ -86,7 +86,7 @@ public void adjust(Mechanism mechanism) {
// @input Element
// @description
// Changes whether a skeleton is a normal or wither type skeleton.
// Valid input: NORMAL, WITHER.
// Valid input: NORMAL, WITHER, STRAY.
// @tags
// <e@entity.skeleton_type>
// -->
Expand Down

0 comments on commit f711026

Please sign in to comment.