Skip to content

Commit

Permalink
Implements the pierce_level property (#2561)
Browse files Browse the repository at this point in the history
* Implements the ``pierce_level`` property

* Meta & if statement change.

* Meta changes

* Another meta change.

* Update EntityArrowPierceLevel.java
  • Loading branch information
heypr committed Nov 15, 2023
1 parent f6e6f29 commit 7b3edf7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Expand Up @@ -36,6 +36,7 @@ public static void registerMainProperties() {
PropertyParser.registerProperty(EntityAreaEffectCloud.class, EntityTag.class);
PropertyParser.registerProperty(EntityArmorBonus.class, EntityTag.class);
PropertyParser.registerProperty(EntityArrowDamage.class, EntityTag.class);
PropertyParser.registerProperty(EntityArrowPierceLevel.class, EntityTag.class);
PropertyParser.registerProperty(EntityAttributeBaseValues.class, EntityTag.class);
PropertyParser.registerProperty(EntityAttributeModifiers.class, EntityTag.class);
PropertyParser.registerProperty(EntityArmorPose.class, EntityTag.class);
Expand Down
@@ -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);
}
}

0 comments on commit 7b3edf7

Please sign in to comment.