Skip to content

Commit

Permalink
Parrot color support
Browse files Browse the repository at this point in the history
  • Loading branch information
mergu committed Jul 2, 2017
1 parent a8baf56 commit 809fb90
Showing 1 changed file with 16 additions and 4 deletions.
Expand Up @@ -24,7 +24,8 @@ public static boolean describes(dObject entity) {
type == EntityType.HORSE ||
type == EntityType.WOLF ||
type == EntityType.OCELOT ||
type == EntityType.RABBIT;
type == EntityType.RABBIT ||
type == EntityType.PARROT;
}

public static EntityColor getFrom(dObject entity) {
Expand Down Expand Up @@ -73,6 +74,10 @@ else if (type == EntityType.RABBIT) {
return ((Rabbit) colored.getBukkitEntity()).getRabbitType().name();
}

else if (type == EntityType.PARROT) {
return ((Parrot) colored.getBukkitEntity()).getVariant().name();
}

else // Should never happen
{
return null;
Expand Down Expand Up @@ -143,10 +148,11 @@ public String getAttribute(Attribute attribute) {
// @group properties
// @description
// If the entity can have a color, returns the entity's color.
// Currently, only Horse, Wolf, Ocelot, Sheep, and Rabbit type entities can have a color.
// Currently, only Horse, Wolf, Ocelot, Sheep, Rabbit, and Parrot type entities can have a color.
// For horses, the output is COLOR|STYLE|VARIANT, see <@link language horse types>.
// For ocelots, the types are BLACK_CAT, RED_CAT, SIAMESE_CAT, or WILD_OCELOT.
// For rabbit types, see <@link language rabbit types>.
// For parrots, the types are BLUE, CYAN, GRAY, GREEN, or RED.
// -->
if (attribute.startsWith("color")) {
return new Element(CoreUtilities.toLowerCase(getColor()))
Expand All @@ -165,10 +171,11 @@ public void adjust(Mechanism mechanism) {
// @input Element
// @description
// Changes the entity's color.
// Currently, only Horse, Wolf, Ocelot, Sheep, and Rabbit type entities can have a color.
// Currently, only Horse, Wolf, Ocelot, Sheep, Rabbit, and Parrot type entities can have a color.
// For horses, the input is COLOR|STYLE|VARIANT, see <@link language horse types>
// For ocelots, the types are BLACK_CAT, RED_CAT, SIAMESE_CAT, or WILD_OCELOT.
// For rabbit types, see <@link language rabbit types>.
// For parrots, the types are BLUE, CYAN, GRAY, GREEN, or RED.
// @tags
// <e@entity.color>
// <e@entity.is_colorable>
Expand Down Expand Up @@ -220,7 +227,12 @@ else if (mechanism.getValue().matchesEnum(Rabbit.Type.values())) {
}
}

else if (type == EntityType.PARROT
&& mechanism.getValue().matchesEnum(Parrot.Variant.values())) {
((Parrot) colored.getBukkitEntity())
.setVariant(Parrot.Variant.valueOf(mechanism.getValue().asString().toUpperCase()));
}

}
}
}

0 comments on commit 809fb90

Please sign in to comment.