Skip to content

Commit

Permalink
Updated should_burn property. (#2560)
Browse files Browse the repository at this point in the history
* ShouldBurn property update.

* Update EntityShouldBurn.java

* Update EntityShouldBurn.java
  • Loading branch information
heypr committed Nov 14, 2023
1 parent ae22abd commit bb58ca5
Showing 1 changed file with 20 additions and 4 deletions.
Expand Up @@ -4,6 +4,8 @@
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.Phantom;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Zombie;

public class EntityShouldBurn extends EntityProperty<ElementTag> {
Expand All @@ -14,16 +16,24 @@ public class EntityShouldBurn extends EntityProperty<ElementTag> {
// @input ElementTag(Boolean)
// @plugin Paper
// @description
// If the entity is a Zombie, controls whether it should burn in daylight.
// If the entity is a Zombie, Skeleton, or Phantom, controls whether it should burn in daylight.
// -->

public static boolean describes(EntityTag entity) {
return entity.getBukkitEntity() instanceof Zombie;
return entity.getBukkitEntity() instanceof Zombie
|| entity.getBukkitEntity() instanceof Skeleton
|| entity.getBukkitEntity() instanceof Phantom;
}

@Override
public ElementTag getPropertyValue() {
return new ElementTag(as(Zombie.class).shouldBurnInDay());
if (getEntity() instanceof Zombie zombie) {
return new ElementTag(zombie.shouldBurnInDay());
}
else if (getEntity() instanceof Skeleton skeleton) {
return new ElementTag(skeleton.shouldBurnInDay());
}
return new ElementTag(as(Phantom.class).shouldBurnInDay());
}

@Override
Expand All @@ -34,7 +44,13 @@ public String getPropertyId() {
@Override
public void setPropertyValue(ElementTag param, Mechanism mechanism) {
if (mechanism.requireBoolean()) {
as(Zombie.class).setShouldBurnInDay(param.asBoolean());
if (getEntity() instanceof Zombie zombie) {
zombie.setShouldBurnInDay(param.asBoolean());
}
else if (getEntity() instanceof Skeleton skeleton) {
skeleton.setShouldBurnInDay(param.asBoolean());
}
as(Phantom.class).setShouldBurnInDay(param.asBoolean());
}
}

Expand Down

0 comments on commit bb58ca5

Please sign in to comment.