From 3ee9fa29125cd52a2b75db7538945c338198ee5c Mon Sep 17 00:00:00 2001 From: Mergu Date: Sat, 30 Dec 2017 21:24:35 -0500 Subject: [PATCH] full Area Effect Cloud support! --- .../aufdemrand/denizen/objects/dEntity.java | 195 +++++++++++++++++- 1 file changed, 184 insertions(+), 11 deletions(-) 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 33689de169..2b20080303 100644 --- a/plugin/src/main/java/net/aufdemrand/denizen/objects/dEntity.java +++ b/plugin/src/main/java/net/aufdemrand/denizen/objects/dEntity.java @@ -2548,7 +2548,7 @@ && getBukkitEntity() instanceof Item) { // @group properties // @description // Returns the Area Effect Cloud's base potion data. - // In the format TYPE,LEVEL,IS_EXTENDED + // In the format Type,Upgraded,Extended // --> if (attribute.startsWith("base_potion")) { PotionData data = ((AreaEffectCloud) entity).getBasePotionData(); @@ -2567,14 +2567,14 @@ && getBukkitEntity() instanceof Item) { } // <--[tag] - // @attribute - // @returns Element(Number) + // @attribute + // @returns Element(Boolean) // @group properties // @description - // Returns the Area Effect Cloud's base potion level. + // Returns whether the Area Effect Cloud's base potion is upgraded. // --> - if (attribute.startsWith("level")) { - return new Element(data.isUpgraded() ? 2 : 1) + if (attribute.startsWith("is_upgraded")) { + return new Element(data.isUpgraded()) .getAttribute(attribute.fulfill(1)); } @@ -2590,7 +2590,7 @@ && getBukkitEntity() instanceof Item) { .getAttribute(attribute.fulfill(1)); } - return new Element(data.getType().name() + "," + (data.isUpgraded() ? 2 : 1) + "," + data.isExtended()) + return new Element(data.getType().name() + "," + data.isUpgraded() + "," + data.isExtended()) .getAttribute(attribute); } @@ -3408,20 +3408,20 @@ && getBukkitEntity() instanceof Sheep) { // @input dList // @description // Adds a list of custom potion effects to the Area Effect Cloud - // In the form Type,Duration,Amplifier(,Ambient,Particles)|... + // In the form Type,Amplifier,Duration(,Ambient,Particles)|... // @tags // // --> if (mechanism.matches("custom_effects")) { - dList list = mechanism.getValue().asType(dList.class); + dList list = value.asType(dList.class); ((AreaEffectCloud) entity).clearCustomEffects(); for (String item : list) { List potionData = CoreUtilities.split(item, ',', 5); if (potionData.size() >= 3) { PotionEffectType type = PotionEffectType.getByName(potionData.get(0)); - Duration duration = Duration.valueOf(potionData.get(1)); - Element amplifier = new Element(potionData.get(2)); + Element amplifier = new Element(potionData.get(1)); + Duration duration = Duration.valueOf(potionData.get(2)); Element ambient = new Element((potionData.size() > 3) ? potionData.get(3) : "false"); Element particles = new Element((potionData.size() > 4) ? potionData.get(4) : "true"); @@ -3439,6 +3439,179 @@ && getBukkitEntity() instanceof Sheep) { } } } + + // <--[mechanism] + // @object dEntity + // @name particle_color + // @input dColor + // @description + // Sets the Area Effect Cloud's particle color. + // @tags + // + // --> + if (mechanism.matches("particle_color") && mechanism.requireObject(dColor.class)) { + ((AreaEffectCloud) entity).setColor(dColor.valueOf(value.asString()).getColor()); + } + + // <--[mechanism] + // @object dEntity + // @name base_potion + // @input Element + // @description + // Sets the Area Effect Cloud's base potion. + // In the form: Type,Upgraded,Extended + // NOTE: Potion cannot be both upgraded and extended + // @tags + // + // + // + // + // --> + if (mechanism.matches("base_potion")) { + List data = CoreUtilities.split(value.asString().toUpperCase(), ','); + if (data.size() != 3) { + dB.echoError(value.asString() + " is not a valid base potion!"); + } + else { + try { + PotionType type = PotionType.valueOf(data.get(0)); + boolean extended = type.isExtendable() && CoreUtilities.toLowerCase(data.get(1)).equals("true"); + boolean upgraded = type.isUpgradeable() && CoreUtilities.toLowerCase(data.get(2)).equals("true"); + if (extended && upgraded) { + dB.echoError("Potion cannot be both upgraded and extended"); + } + else { + ((AreaEffectCloud) entity).setBasePotionData( + new PotionData(type, extended, upgraded)); + } + } + catch (Exception e) { + dB.echoError(value.asString() + " is not a valid base potion!"); + } + } + } + + // <--[mechanism] + // @object dEntity + // @name duration + // @input Duration + // @description + // Sets the Area Effect Cloud's duration. + // @tags + // + // --> + if (mechanism.matches("duration") && mechanism.requireObject(Duration.class)) { + ((AreaEffectCloud) entity).setDuration(Duration.valueOf(value.asString()).getTicksAsInt()); + } + + // <--[mechanism] + // @object dEntity + // @name duration_on_use + // @input Duration + // @description + // Sets the duration the Area Effect Cloud + // will decrease by when it applies an effect to an entity. + // @tags + // + // --> + if (mechanism.matches("duration_on_use") && mechanism.requireObject(Duration.class)) { + ((AreaEffectCloud) entity).setDurationOnUse(Duration.valueOf(value.asString()).getTicksAsInt()); + } + + // <--[mechanism] + // @object dEntity + // @name particle + // @input Element + // @description + // Sets the particle of the Area Effect Cloud + // @tags + // + // --> + if (mechanism.matches("particle") && mechanism.requireEnum(false, Particle.values())) { + ((AreaEffectCloud) entity).setParticle(Particle.valueOf(value.asString().toUpperCase())); + } + + // <--[mechanism] + // @object dEntity + // @name radius + // @input Element(Decimal) + // @description + // Sets the radius of the Area Effect Cloud + // @tags + // + // --> + if (mechanism.matches("radius") && mechanism.requireFloat()) { + ((AreaEffectCloud) entity).setRadius(value.asFloat()); + } + + // <--[mechanism] + // @object dEntity + // @name radius_on_use + // @input Element(Decimal) + // @description + // Sets the radius the Area Effect Cloud + // will decrease by when it applies an effect to an entity. + // @tags + // + // --> + if (mechanism.matches("radius_on_use") && mechanism.requireFloat()) { + ((AreaEffectCloud) entity).setRadiusOnUse(value.asFloat()); + } + + // <--[mechanism] + // @object dEntity + // @name radius_per_tick + // @input Element(Decimal) + // @description + // Sets the radius the Area Effect Cloud + // will decrease by every tick. + // @tags + // + // --> + if (mechanism.matches("radius_per_tick") && mechanism.requireFloat()) { + ((AreaEffectCloud) entity).setRadiusPerTick(value.asFloat()); + } + + // <--[mechanism] + // @object dEntity + // @name reapplication_delay + // @input Duration + // @description + // Sets the duration an entity will be immune + // from the Area Effect Cloud's subsequent exposure. + // @tags + // + // --> + if (mechanism.matches("reapplication_delay") && mechanism.requireObject(Duration.class)) { + ((AreaEffectCloud) entity).setReapplicationDelay(Duration.valueOf(value.asString()).getTicksAsInt()); + } + + // <--[mechanism] + // @object dEntity + // @name source + // @input dEntity + // @description + // Sets the source of the Area Effect Cloud + // @tags + // + // --> + if (mechanism.matches("source") && mechanism.requireObject(dEntity.class)) { + ((AreaEffectCloud) entity).setSource((ProjectileSource) dEntity.valueOf(value.asString()).getBukkitEntity()); + } + + // <--[mechanism] + // @object dEntity + // @name wait_time + // @input Duration + // @description + // Sets the duration an entity must be exposed to + // the Area Effect Cloud before its effect is applied. + // @tags + // + // --> + if (mechanism.matches("wait_time") && mechanism.requireObject(Duration.class)) { + ((AreaEffectCloud) entity).setWaitTime(Duration.valueOf(value.asString()).getTicksAsInt()); + } } // Iterate through this object's properties' mechanisms