Skip to content

Commit

Permalink
full Area Effect Cloud support!
Browse files Browse the repository at this point in the history
  • Loading branch information
mergu committed Dec 31, 2017
1 parent 1dcc5f6 commit 3ee9fa2
Showing 1 changed file with 184 additions and 11 deletions.
195 changes: 184 additions & 11 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dEntity.java
Expand Up @@ -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();
Expand All @@ -2567,14 +2567,14 @@ && getBukkitEntity() instanceof Item) {
}

// <--[tag]
// @attribute <e@entity.base_potion.level>
// @returns Element(Number)
// @attribute <e@entity.base_potion.is_upgraded>
// @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));
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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
// <e@entity.custom_effects>
// -->
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<String> 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");

Expand All @@ -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
// <e@entity.particle.color>
// -->
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
// <e@entity.base_potion>
// <e@entity.base_potion.type>
// <e@entity.base_potion.is_upgraded>
// <e@entity.base_potion.is_extended>
// -->
if (mechanism.matches("base_potion")) {
List<String> 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
// <e@entity.duration>
// -->
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
// <e@entity.duration.on_use>
// -->
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
// <e@entity.particle>
// -->
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
// <e@entity.radius>
// -->
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
// <e@entity.radius.on_use>
// -->
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
// <e@entity.radius.per_tick>
// -->
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
// <e@entity.reapplication_delay>
// -->
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
// <e@entity.source>
// -->
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
// <e@entity.wait_time>
// -->
if (mechanism.matches("wait_time") && mechanism.requireObject(Duration.class)) {
((AreaEffectCloud) entity).setWaitTime(Duration.valueOf(value.asString()).getTicksAsInt());
}
}

// Iterate through this object's properties' mechanisms
Expand Down

0 comments on commit 3ee9fa2

Please sign in to comment.