From c3574dc20922d1df76e6ced0f4218cc61d951bd8 Mon Sep 17 00:00:00 2001 From: Brando! <63469489+BreadcrumbIsTaken@users.noreply.github.com> Date: Sat, 24 Jun 2023 02:36:22 -0700 Subject: [PATCH] Add new property `should_burn` for Zombies (#2488) --- .../denizen/paper/PaperModule.java | 1 + .../paper/properties/EntityShouldBurn.java | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 paper/src/main/java/com/denizenscript/denizen/paper/properties/EntityShouldBurn.java diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/PaperModule.java b/paper/src/main/java/com/denizenscript/denizen/paper/PaperModule.java index fdc3ea45f0..75706ade75 100644 --- a/paper/src/main/java/com/denizenscript/denizen/paper/PaperModule.java +++ b/paper/src/main/java/com/denizenscript/denizen/paper/PaperModule.java @@ -100,6 +100,7 @@ public static void init() { PropertyParser.registerProperty(EntityFriction.class, EntityTag.class); } PropertyParser.registerProperty(EntityReputation.class, EntityTag.class); + PropertyParser.registerProperty(EntityShouldBurn.class, EntityTag.class); PropertyParser.registerProperty(EntityWitherInvulnerable.class, EntityTag.class); PropertyParser.registerProperty(ItemArmorStand.class, ItemTag.class); diff --git a/paper/src/main/java/com/denizenscript/denizen/paper/properties/EntityShouldBurn.java b/paper/src/main/java/com/denizenscript/denizen/paper/properties/EntityShouldBurn.java new file mode 100644 index 0000000000..a4e67fec6d --- /dev/null +++ b/paper/src/main/java/com/denizenscript/denizen/paper/properties/EntityShouldBurn.java @@ -0,0 +1,44 @@ +package com.denizenscript.denizen.paper.properties; + +import com.denizenscript.denizen.objects.EntityTag; +import com.denizenscript.denizen.objects.properties.entity.EntityProperty; +import com.denizenscript.denizencore.objects.Mechanism; +import com.denizenscript.denizencore.objects.core.ElementTag; +import org.bukkit.entity.Zombie; + +public class EntityShouldBurn extends EntityProperty { + + // <--[property] + // @object EntityTag + // @name should_burn + // @input ElementTag(Boolean) + // @plugin Paper + // @description + // If the entity is a Zombie, controls whether it should burn in daylight. + // --> + + public static boolean describes(EntityTag entity) { + return entity.getBukkitEntity() instanceof Zombie; + } + + @Override + public ElementTag getPropertyValue() { + return new ElementTag(as(Zombie.class).shouldBurnInDay()); + } + + @Override + public String getPropertyId() { + return "should_burn"; + } + + @Override + public void setPropertyValue(ElementTag param, Mechanism mechanism) { + if (mechanism.requireBoolean()) { + as(Zombie.class).setShouldBurnInDay(param.asBoolean()); + } + } + + public static void register() { + autoRegister("should_burn", EntityShouldBurn.class, ElementTag.class, false); + } +}