Skip to content

Commit

Permalink
EntityTag.color: frogge
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 7, 2022
1 parent 2559a48 commit 0432b22
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
Expand Up @@ -740,7 +740,7 @@ else if (isAdvancedMatchable(lower)) {
}
else {
if (context.showErrors()) {
Debug.echoError("Invalid event 'in:<area>' switch [" + name + "] ('in:???') (did you make a typo, or forget to make a notable by that name?): '" + evtLine + "' for " + containerName);
Debug.echoError("Invalid event 'in:<area>' switch [" + name + "] ('in:???') (did you make a typo, or forget to 'note' an object with that name?): '" + evtLine + "' for " + containerName);
}
return false;
}
Expand Down
Expand Up @@ -26,7 +26,7 @@ public class PlayerWalksOverScriptEvent extends BukkitScriptEvent implements Lis
//
// @Cancellable true
//
// @Triggers when a player walks over a notable location. In most cases, it is preferable to use <@link event player enters area> with a small cuboid.
// @Triggers when a player walks over a noted location. In most cases, it is preferable to use <@link event player enters area> with a small cuboid.
//
// @Context
// <context.notable> returns an ElementTag of the notable location's name.
Expand Down
Expand Up @@ -5,6 +5,7 @@
import com.denizenscript.denizen.objects.ColorTag;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.utilities.MultiVersionHelper1_17;
import com.denizenscript.denizen.utilities.MultiVersionHelper1_19;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ListTag;
Expand Down Expand Up @@ -41,7 +42,8 @@ public static boolean describes(ObjectTag entity) {
type == EntityType.ZOMBIE_VILLAGER ||
type == EntityType.TRADER_LLAMA ||
type == EntityType.TROPICAL_FISH ||
(NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && MultiVersionHelper1_17.colorIsApplicable(type));
(NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && MultiVersionHelper1_17.colorIsApplicable(type)) ||
(NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19) && MultiVersionHelper1_19.colorIsApplicable(type));
}

public static EntityColor getFrom(ObjectTag entity) {
Expand Down Expand Up @@ -116,6 +118,9 @@ public String getColor(boolean includeDeprecated) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && MultiVersionHelper1_17.colorIsApplicable(type)) {
return MultiVersionHelper1_17.getColor(colored.getBukkitEntity());
}
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19) && MultiVersionHelper1_19.colorIsApplicable(type)) {
return MultiVersionHelper1_19.getColor(colored.getBukkitEntity());
}
return null;
}

Expand Down Expand Up @@ -160,10 +165,13 @@ public ListTag getAllowedColors() {
case VILLAGER:
case ZOMBIE_VILLAGER:
return listForEnum(Villager.Type.values());
}
}
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && MultiVersionHelper1_17.colorIsApplicable(type)) {
return MultiVersionHelper1_17.getAllowedColors(type);
}
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19) && MultiVersionHelper1_19.colorIsApplicable(type)) {
return MultiVersionHelper1_19.getAllowedColors(type);
}
return null; // includes Ocelot (deprecated) and arrow (ColorTag)
}

Expand Down Expand Up @@ -204,7 +212,8 @@ public String getPropertyId() {
// For sheep, wolf, and shulker entities, the input is a Dye Color.
// For Tipped Arrow entities, the input is a ColorTag.
// For goats, the input is SCREAMING or NORMAL.
// For axolotl, the input is BLUE, CYAN, GOLD, LUCY, or WILD.
// For axolotl, the types are BLUE, CYAN, GOLD, LUCY, or WILD.
// For frogs, the types are TEMPERATE, WARM, or COLD.
//
// For all places where a DyeColor is needed, the options are:
// BLACK, BLUE, BROWN, CYAN, GRAY, GREEN, LIGHT_BLUE, LIGHT_GRAY, LIME, MAGENTA, ORANGE, PINK, PURPLE, RED, WHITE, or YELLOW.
Expand Down Expand Up @@ -387,6 +396,9 @@ else if (type == EntityType.ARROW && mechanism.requireObject(ColorTag.class)) {
else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && MultiVersionHelper1_17.colorIsApplicable(type)) {
MultiVersionHelper1_17.setColor(colored.getBukkitEntity(), mechanism);
}
else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19) && MultiVersionHelper1_19.colorIsApplicable(type)) {
MultiVersionHelper1_19.setColor(colored.getBukkitEntity(), mechanism);
}
}
}
}
@@ -0,0 +1,33 @@
package com.denizenscript.denizen.utilities;

import com.denizenscript.denizen.objects.properties.entity.EntityColor;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ListTag;
import org.bukkit.entity.*;

public class MultiVersionHelper1_19 {

public static boolean colorIsApplicable(EntityType type) {
return type == EntityType.FROG;
}

public static String getColor(Entity entity) {
if (entity instanceof Frog) {
return ((Frog) entity).getVariant().name();
}
return null;
}

public static ListTag getAllowedColors(EntityType type) {
if (type == EntityType.FROG) {
return EntityColor.listForEnum(Frog.Variant.values());
}
return null;
}

public static void setColor(Entity entity, Mechanism mech) {
if (entity instanceof Frog && mech.requireEnum(Frog.Variant.class)) {
((Frog) entity).setVariant(Frog.Variant.valueOf(mech.getValue().asString().toUpperCase()));
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -10,7 +10,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.18.2-R0.1-SNAPSHOT</craftbukkit.version>
<craftbukkit.version>1.19-R0.1-SNAPSHOT</craftbukkit.version>
<citizens.version>2.0.29-SNAPSHOT</citizens.version>
<dcore.version>1.90.1-SNAPSHOT</dcore.version>
<BUILD_NUMBER>Unknown</BUILD_NUMBER>
Expand Down

0 comments on commit 0432b22

Please sign in to comment.