Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements the
pierce_level
property (#2561)
* Implements the ``pierce_level`` property * Meta & if statement change. * Meta changes * Another meta change. * Update EntityArrowPierceLevel.java
- Loading branch information
Showing
2 changed files
with
43 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
42 changes: 42 additions & 0 deletions
42
...main/java/com/denizenscript/denizen/objects/properties/entity/EntityArrowPierceLevel.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,42 @@ | ||
package com.denizenscript.denizen.objects.properties.entity; | ||
|
||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import org.bukkit.entity.AbstractArrow; | ||
|
||
public class EntityArrowPierceLevel extends EntityProperty<ElementTag> { | ||
|
||
// <--[property] | ||
// @object EntityTag | ||
// @name pierce_level | ||
// @input ElementTag(Number) | ||
// @description | ||
// The number of entities an arrow will pierce through while flying. Must be between 0 and 127. | ||
// --> | ||
|
||
public static boolean describes(EntityTag entity) { | ||
return entity.getBukkitEntity() instanceof AbstractArrow; | ||
} | ||
|
||
@Override | ||
public ElementTag getPropertyValue() { | ||
return new ElementTag(as(AbstractArrow.class).getPierceLevel()); | ||
} | ||
|
||
@Override | ||
public void setPropertyValue(ElementTag value, Mechanism mechanism) { | ||
if (mechanism.requireInteger()) { | ||
as(AbstractArrow.class).setPierceLevel(value.asInt()); | ||
} | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "pierce_level"; | ||
} | ||
|
||
public static void register() { | ||
autoRegister("pierce_level", EntityArrowPierceLevel.class, ElementTag.class, false); | ||
} | ||
} |