diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandRegistry.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandRegistry.java index d1c5059c53..d5bd09c5b0 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandRegistry.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandRegistry.java @@ -218,7 +218,7 @@ public void registerCoreMembers() { "OXYGEN", "oxygen (type:maximum|remaining) (mode:set|add|remove) [qty:<#>]", 1); registerCoreMember(PlayEffectCommand.class, - "PLAYEFFECT", "playeffect [location:] [effect:] (data:<#>) (radius:<#>)", 2); + "PLAYEFFECT", "playeffect [location:] [effect:] (data:<#>) (radius:<#>) (qty:<#>)", 2); registerCoreMember(PlaySoundCommand.class, "PLAYSOUND", "playsound [location:] [sound:] (volume:<#>) (pitch:<#>)", 2); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/AnimateCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/AnimateCommand.java index f33376af16..d239b4c578 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/AnimateCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/AnimateCommand.java @@ -36,7 +36,8 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException scriptEntry.addObject("entities", ((dList) arg.asType(dList.class)).filter(dEntity.class)); } - if (!scriptEntry.hasObject("animation")) { + if (!scriptEntry.hasObject("animation") && + !scriptEntry.hasObject("effect")) { if (arg.matchesEnum(PlayerAnimation.values())) { scriptEntry.addObject("animation", PlayerAnimation.valueOf(arg.getValue().toUpperCase())); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java index e4c2e0881f..abc402b609 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/world/PlayEffectCommand.java @@ -13,8 +13,6 @@ import net.aufdemrand.denizen.utilities.debugging.dB.Messages; import net.aufdemrand.denizen.utilities.ParticleEffect; -/* playeffect [location:] [effect:] (data:<#>) (radius:<#>)*/ - /** * Lets you play a Bukkit effect or a ParticleEffect from the * ParticleEffect Library at a certain location. @@ -24,10 +22,12 @@ * [effect:] sets the name of effect to be played * (data:<#>) sets the special data value of the effect * (radius:<#>) adjusts the radius within which players will observe the effect + * (qty:<#>) sets the number of times the effect will be played * * Example Usage: * playeffect location:123,65,765,world effect:record_play data:2259 radius:7 * playeffect location: e:smoke r:3 + * playeffect location: effect:heart radius:7 qty:60 * * @author David Cernat */ @@ -46,14 +46,16 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException scriptEntry.addObject("location", arg.asType(dLocation.class)); } - if (!scriptEntry.hasObject("effect")) { + else if (!scriptEntry.hasObject("effect") && + !scriptEntry.hasObject("particleeffect")) { // Add effect if (arg.matchesEnum(Effect.values())) { scriptEntry.addObject("effect", Effect.valueOf(arg.getValue().toUpperCase())); } else if (arg.matchesEnum(ParticleEffect.values())) { - scriptEntry.addObject("specialeffect", ParticleEffect.valueOf(arg.getValue().toUpperCase())); + scriptEntry.addObject("particleeffect", + ParticleEffect.valueOf(arg.getValue().toUpperCase())); } } @@ -70,6 +72,13 @@ else if (!scriptEntry.hasObject("data") // Add value scriptEntry.addObject("data", arg.asElement()); } + + else if (!scriptEntry.hasObject("qty") + && arg.matchesPrimitive(aH.PrimitiveType.Integer) + && arg.matchesPrefix("qty, q")) { + // Add value + scriptEntry.addObject("qty", arg.asElement()); + } } // Check to make sure required arguments have been filled @@ -77,10 +86,11 @@ else if (!scriptEntry.hasObject("data") if ((!scriptEntry.hasObject("location"))) throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "LOCATION"); - if (!scriptEntry.hasObject("effect") && !scriptEntry.hasObject("specialeffect")) + if (!scriptEntry.hasObject("effect") && + !scriptEntry.hasObject("particleeffect")) throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "EFFECT"); - // Use a default radius and data if necessary + // Use default radius, data and qty if necessary if ((!scriptEntry.hasObject("radius"))) { scriptEntry.addObject("radius", new Element(5)); @@ -89,6 +99,10 @@ else if (!scriptEntry.hasObject("data") if ((!scriptEntry.hasObject("data"))) { scriptEntry.addObject("data", new Element(0)); } + + if ((!scriptEntry.hasObject("qty"))) { + scriptEntry.addObject("qty", new Element(1)); + } } @Override @@ -97,28 +111,37 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { // Extract objects from ScriptEntry dLocation location = (dLocation) scriptEntry.getObject("location"); Effect effect = (Effect) scriptEntry.getObject("effect"); - ParticleEffect particleEffect = (ParticleEffect) scriptEntry.getObject("specialeffect"); + ParticleEffect particleEffect = (ParticleEffect) scriptEntry.getObject("particleeffect"); Element radius = (Element) scriptEntry.getObject("radius"); Element data = (Element) scriptEntry.getObject("data"); + Element qty = (Element) scriptEntry.getObject("qty"); + // Slightly increase the location's Y so effects don't seem + // to come out of the ground + location.add(0, 1, 0); + // Report to dB dB.report(getName(), (effect != null ? aH.debugObj("effect", effect.name()) : aH.debugObj("special effect", particleEffect.name())) + - aH.debugObj("location", location.toString() + + aH.debugObj("location", location.toString()) + aH.debugObj("radius", radius) + - aH.debugObj("data", data))); + aH.debugObj("data", data) + + aH.debugObj("qty", qty)); - // Play the Bukkit effect + // Play the Bukkit effect the number of times specified if (effect != null) { - location.getWorld().playEffect(location, effect, data.asInt(), radius.asInt()); + + for (int n = 0; n < qty.asInt(); n++) { + location.getWorld().playEffect(location, effect, data.asInt(), radius.asInt()); + } } - // Play one of the special effects + // Play a ParticleEffect else { ParticleEffect.fromName(particleEffect.name()) .play(location, radius.asDouble(), - 1.0F, 1.0F, 1.0F, 1.0F, 3); + 0.5F, 0.5F, 0.5F, 1.0F, qty.asInt()); } } }