diff --git a/plugin/src/main/java/net/aufdemrand/denizen/objects/properties/entity/EntityColor.java b/plugin/src/main/java/net/aufdemrand/denizen/objects/properties/entity/EntityColor.java index 02172654a1..ca5e20ecd8 100644 --- a/plugin/src/main/java/net/aufdemrand/denizen/objects/properties/entity/EntityColor.java +++ b/plugin/src/main/java/net/aufdemrand/denizen/objects/properties/entity/EntityColor.java @@ -7,6 +7,7 @@ import net.aufdemrand.denizen.utilities.entity.LlamaHelper; import net.aufdemrand.denizen.utilities.entity.ParrotHelper; import net.aufdemrand.denizen.utilities.entity.RabbitType; +import net.aufdemrand.denizen.utilities.entity.ShulkerHelper; import net.aufdemrand.denizencore.objects.Element; import net.aufdemrand.denizencore.objects.Mechanism; import net.aufdemrand.denizencore.objects.dList; @@ -31,7 +32,8 @@ public static boolean describes(dObject entity) { type == EntityType.OCELOT || type == EntityType.RABBIT || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_11_R1) && type == EntityType.LLAMA) || - (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_12_R1) && type == EntityType.PARROT); + (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_12_R1) + && (type == EntityType.PARROT || type == EntityType.SHULKER)); } public static EntityColor getFrom(dObject entity) { @@ -88,6 +90,9 @@ else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_11_R1) && type == Entit else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_12_R1) && type == EntityType.PARROT) { return ParrotHelper.parrotColor(colored); } + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_12_R1) && type == EntityType.SHULKER) { + return ShulkerHelper.getColor(colored).name(); + } else // Should never happen { return null; @@ -166,6 +171,7 @@ public String getAttribute(Attribute attribute) { // For rabbit types, see <@link language rabbit types>. // For parrots, the types are BLUE, CYAN, GRAY, GREEN, or RED. // For llamas, the types are CREAMY, WHITE, BROWN, and GRAY. + // For sheep, wolf, and shulker entities, see <@link url https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/DyeColor.html> // --> if (attribute.startsWith("color")) { return new Element(CoreUtilities.toLowerCase(getColor())) @@ -184,12 +190,14 @@ public void adjust(Mechanism mechanism) { // @input Element // @description // Changes the entity's color. - // Currently, only Horse, Wolf, Ocelot, Sheep, Rabbit, and Parrot type entities can have a color. + // Currently, only Horse, Wolf, Ocelot, Sheep, Rabbit, Llama, Parrot, and Shulker type entities can have a color. // For horses, the input is COLOR|STYLE(|VARIANT), see <@link language horse types> // NOTE: HORSE VARIANTS DEPRECATED SINCE 1.11, use spawn instead // 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. + // For llamas, the types are CREAMY, WHITE, BROWN, and GRAY. + // For sheep, wolf, and shulker entities, see <@link url https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/DyeColor.html> // @tags // // @@ -243,6 +251,10 @@ else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_11_R1) && type == Entit else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_12_R1) && type == EntityType.PARROT) { ParrotHelper.setParrotColor(colored, mechanism); } + else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_12_R1) && type == EntityType.SHULKER + && mechanism.getValue().matchesEnum(DyeColor.values())) { + ShulkerHelper.setColor(colored, DyeColor.valueOf(mechanism.getValue().asString().toUpperCase())); + } else { dB.echoError("Could not apply color '" + mechanism.getValue().toString() + "' to entity of type " + type.name() + "."); } diff --git a/plugin/src/main/java/net/aufdemrand/denizen/utilities/entity/ShulkerHelper.java b/plugin/src/main/java/net/aufdemrand/denizen/utilities/entity/ShulkerHelper.java new file mode 100644 index 0000000000..705784dfea --- /dev/null +++ b/plugin/src/main/java/net/aufdemrand/denizen/utilities/entity/ShulkerHelper.java @@ -0,0 +1,16 @@ +package net.aufdemrand.denizen.utilities.entity; + +import net.aufdemrand.denizen.objects.dEntity; +import org.bukkit.DyeColor; +import org.bukkit.entity.Shulker; + +public class ShulkerHelper { + + public static DyeColor getColor(dEntity shulker) { + return ((Shulker) shulker.getBukkitEntity()).getColor(); + } + + public static void setColor(dEntity shulker, DyeColor color) { + ((Shulker) shulker.getBukkitEntity()).setColor(color); + } +}