diff --git a/plugin/src/main/java/net/aufdemrand/denizen/objects/dEntity.java b/plugin/src/main/java/net/aufdemrand/denizen/objects/dEntity.java index 0bb901de61..a373f2adbd 100644 --- a/plugin/src/main/java/net/aufdemrand/denizen/objects/dEntity.java +++ b/plugin/src/main/java/net/aufdemrand/denizen/objects/dEntity.java @@ -39,6 +39,7 @@ import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; import java.util.*; @@ -2545,143 +2546,271 @@ && getBukkitEntity() instanceof Item) { // AREA EFFECT CLOUD ATTRIBUTES ///////////////// - // <--[tag] - // @attribute - // @returns Element - // @group properties - // @description - // Returns the Area Effect Cloud's base potion data. - // In the format Effect,Level,Extended - // --> - if (attribute.startsWith("base_potion") && entity instanceof AreaEffectCloud) { - PotionData data = ((AreaEffectCloud) entity).getBasePotionData(); - return new Element(data.getType().name() + "," + (data.isUpgraded() ? 2 : 1) + "," + data.isExtended()) - .getAttribute(attribute.fulfill(1)); - } + if (entity instanceof AreaEffectCloud) { + + // <--[tag] + // @attribute + // @returns Element + // @group properties + // @description + // Returns the Area Effect Cloud's base potion data. + // In the format Effect,Level,Extended + // --> + if (attribute.startsWith("base_potion")) { + PotionData data = ((AreaEffectCloud) entity).getBasePotionData(); + return new Element(data.getType().name() + "," + (data.isUpgraded() ? 2 : 1) + "," + data.isExtended()) + .getAttribute(attribute.fulfill(1)); + } - // <--[tag] - // @attribute - // @returns Element - // @group properties - // @description - // Returns the Area Effect Cloud's particle - // --> - if (attribute.startsWith("particle") && entity instanceof AreaEffectCloud) { - return new Element(((AreaEffectCloud) entity).getParticle().name()) - .getAttribute(attribute.fulfill(1)); - } + // <--[tag] + // @attribute + // @returns Element + // @group properties + // @description + // Returns the Area Effect Cloud's particle. + // --> + if (attribute.startsWith("particle")) { + attribute = attribute.fulfill(1); - // <--[tag] - // @attribute - // @returns dColor - // @group properties - // @description - // Returns the Area Effect Cloud's color. - // --> - if (attribute.startsWith("particle_color") && entity instanceof AreaEffectCloud) { - return new dColor(((AreaEffectCloud) entity).getColor()) - .getAttribute(attribute.fulfill(1)); - } + // <--[tag] + // @attribute + // @returns dColor + // @group properties + // @description + // Returns the Area Effect Cloud's particle color. + // --> + if (attribute.startsWith("color")) { + return new dColor(((AreaEffectCloud) entity).getColor()) + .getAttribute(attribute.fulfill(1)); + } - // <--[tag] - // @attribute - // @returns Duration - // @group properties - // @description - // Returns the Area Effect Cloud's duration. - // --> - if (attribute.startsWith("duration") && entity instanceof AreaEffectCloud) { - return new Duration((long) ((AreaEffectCloud) entity).getDuration()) - .getAttribute(attribute.fulfill(1)); - } + return new Element(((AreaEffectCloud) entity).getParticle().name()) + .getAttribute(attribute); + } - // <--[tag] - // @attribute - // @returns Duration - // @group properties - // @description - // Returns the duration the Area Effect Cloud - // will decrease by when it applies an effect to an entity. - // --> - if (attribute.startsWith("duration_on_use") && entity instanceof AreaEffectCloud) { - return new Duration((long) ((AreaEffectCloud) entity).getDurationOnUse()) - .getAttribute(attribute.fulfill(1)); - } + // <--[tag] + // @attribute + // @returns Duration + // @group properties + // @description + // Returns the Area Effect Cloud's duration. + // --> + if (attribute.startsWith("duration")) { + attribute = attribute.fulfill(1); - // <--[tag] - // @attribute - // @returns Element(Number) - // @group properties - // @description - // Returns the Area Effect Cloud's radius. - // --> - if (attribute.startsWith("radius") && entity instanceof AreaEffectCloud) { - return new Element(((AreaEffectCloud) entity).getRadius()) - .getAttribute(attribute.fulfill(1)); - } + // <--[tag] + // @attribute + // @returns Duration + // @group properties + // @description + // Returns the duration the Area Effect Cloud + // will decrease by when it applies an effect to an entity. + // --> + if (attribute.startsWith("on_use")) { + return new Duration((long) ((AreaEffectCloud) entity).getDurationOnUse()) + .getAttribute(attribute.fulfill(1)); + } - // <--[tag] - // @attribute - // @returns Element(Number) - // @group properties - // @description - // Returns the amount the Area Effect Cloud's radius - // will decrease by when it applies an effect to an entity. - // --> - if (attribute.startsWith("radius_on_use") && entity instanceof AreaEffectCloud) { - return new Element(((AreaEffectCloud) entity).getRadiusOnUse()) - .getAttribute(attribute.fulfill(1)); - } + return new Duration((long) ((AreaEffectCloud) entity).getDuration()) + .getAttribute(attribute); + } - // <--[tag] - // @attribute - // @returns Element(Number) - // @group properties - // @description - // Returns the amount the Area Effect Cloud's radius - // will decrease by every tick. - // --> - if (attribute.startsWith("radius_per_tick") && entity instanceof AreaEffectCloud) { - return new Element(((AreaEffectCloud) entity).getRadiusPerTick()) - .getAttribute(attribute.fulfill(1)); - } + // <--[tag] + // @attribute + // @returns Element(Number) + // @group properties + // @description + // Returns the Area Effect Cloud's radius. + // --> + if (attribute.startsWith("radius")) { + attribute = attribute.fulfill(1); - // <--[tag] - // @attribute - // @returns Duration - // @group properties - // @description - // Returns the duration an entity will be immune - // from the Area Effect Cloud's subsequent exposure. - // --> - if (attribute.startsWith("reapplication_delay") && entity instanceof AreaEffectCloud) { - return new Duration((long) ((AreaEffectCloud) entity).getReapplicationDelay()) - .getAttribute(attribute.fulfill(1)); - } + // <--[tag] + // @attribute + // @returns Element(Number) + // @group properties + // @description + // Returns the amount the Area Effect Cloud's radius + // will decrease by when it applies an effect to an entity. + // --> + if (attribute.startsWith("on_use")) { + return new Element(((AreaEffectCloud) entity).getRadiusOnUse()) + .getAttribute(attribute.fulfill(1)); + } - // <--[tag] - // @attribute - // @returns Duration - // @group properties - // @description - // Returns the duration an entity must be exposed to - // the Area Effect Cloud before its effect is applied. - // --> - if (attribute.startsWith("wait_time") && entity instanceof AreaEffectCloud) { - return new Duration((long) ((AreaEffectCloud) entity).getWaitTime()) - .getAttribute(attribute.fulfill(1)); - } + // <--[tag] + // @attribute + // @returns Element(Number) + // @group properties + // @description + // Returns the amount the Area Effect Cloud's radius + // will decrease by every tick. + // --> + if (attribute.startsWith("per_tick")) { + return new Element(((AreaEffectCloud) entity).getRadiusPerTick()) + .getAttribute(attribute.fulfill(1)); + } - // <--[tag] - // @attribute - // @returns Element(Boolean) - // @group properties - // @description - // Returns whether the Area Effect Cloud has custom effects. - // --> - if (attribute.startsWith("has_custom_effects") && entity instanceof AreaEffectCloud) { - return new Element(((AreaEffectCloud) entity).hasCustomEffects()) - .getAttribute(attribute.fulfill(1)); + return new Element(((AreaEffectCloud) entity).getRadius()) + .getAttribute(attribute); + } + + // <--[tag] + // @attribute + // @returns Duration + // @group properties + // @description + // Returns the duration an entity will be immune + // from the Area Effect Cloud's subsequent exposure. + // --> + if (attribute.startsWith("reapplication_delay")) { + return new Duration((long) ((AreaEffectCloud) entity).getReapplicationDelay()) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns Duration + // @group properties + // @description + // Returns the duration an entity must be exposed to + // the Area Effect Cloud before its effect is applied. + // --> + if (attribute.startsWith("wait_time")) { + return new Duration((long) ((AreaEffectCloud) entity).getWaitTime()) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns Element(Boolean) + // @group properties + // @description + // Returns whether the Area Effect Cloud has custom effects. + // --> + if (attribute.startsWith("has_custom_effects")) { + return new Element(((AreaEffectCloud) entity).hasCustomEffects()) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute + // @returns dEntity + // @group properties + // @description + // Returns the source of the Area Effect Cloud. + // --> + if (attribute.startsWith("source")) { + ProjectileSource shooter = ((AreaEffectCloud) entity).getSource(); + if (shooter != null && shooter instanceof LivingEntity) { + return new dEntity((LivingEntity) shooter) + .getAttribute(attribute.fulfill(1)); + } + } + + // <--[tag] + // @attribute + // @returns dList + // @group properties + // @description + // Returns a dList of the Area Effect Cloud's custom effects. + // --> + if (attribute.startsWith("custom_effects")) { + List effects = ((AreaEffectCloud) entity).getCustomEffects(); + + if (!attribute.hasContext(1)) { + dList list = new dList(); + for (PotionEffect effect : effects) { + list.add(effect.getType().getName() + "," + + effect.getAmplifier() + "," + + new Duration((long) effect.getDuration()).identify() + "," + + effect.hasParticles() + "," + + effect.isAmbient() + "," + + new dColor(effect.getColor()).identify()); + } + return list.getAttribute(attribute.fulfill(1)); + } + + int val = attribute.getIntContext(1) - 1; + if (val < 0 || val >= effects.size()) { + return null; + } + + attribute = attribute.fulfill(1); + PotionEffect effect = effects.get(val); + + // <--[tag] + // @attribute ].type> + // @returns Element + // @group properties + // @description + // Returns the specified Area Effect Cloud potion effect type. + // --> + if (attribute.startsWith("type")) { + return new Element(effect.getType().getName()) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute ].amplifier> + // @returns Element(Number) + // @group properties + // @description + // Returns the specified Area Effect Cloud potion effect amplifier. + // --> + if (attribute.startsWith("amplifier")) { + return new Element(effect.getAmplifier()) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute ].duration> + // @returns Duration + // @group properties + // @description + // Returns the specified Area Effect Cloud potion effect duration. + // --> + if (attribute.startsWith("duration")) { + return new Duration((long) effect.getDuration()) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute ].has_particles> + // @returns Element(Boolean) + // @group properties + // @description + // Returns whether the specified Area Effect Cloud potion effect has particles. + // --> + if (attribute.startsWith("has_particles")) { + return new Element(effect.hasParticles()) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute ].is_ambient> + // @returns Element(Boolean) + // @group properties + // @description + // Returns whether the specified Area Effect Cloud potion effect is ambient. + // --> + if (attribute.startsWith("is_ambient")) { + return new Element(effect.isAmbient()) + .getAttribute(attribute.fulfill(1)); + } + + // <--[tag] + // @attribute ].color> + // @returns dColor + // @group properties + // @description + // Returns the specified Area Effect Cloud potion effect color. + // --> + if (attribute.startsWith("color")) { + return new dColor(effect.getColor()) + .getAttribute(attribute.fulfill(1)); + } + } } // Iterate through this object's properties' attributes