Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new property
should_burn
for Zombies (#2488)
- Loading branch information
1 parent
363e6a4
commit c3574dc
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
paper/src/main/java/com/denizenscript/denizen/paper/properties/EntityShouldBurn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |