Skip to content

Commit

Permalink
Add new property should_burn for Zombies (#2488)
Browse files Browse the repository at this point in the history
  • Loading branch information
BreadcrumbIsTaken committed Jun 24, 2023
1 parent 363e6a4 commit c3574dc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Expand Up @@ -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);

Expand Down
@@ -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<ElementTag> {

// <--[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);
}
}

0 comments on commit c3574dc

Please sign in to comment.