From 3962553ff3a39f636fae3e3c0b581e6ea8f00f0b Mon Sep 17 00:00:00 2001 From: "Alex \"mcmonkey\" Goodwin" Date: Fri, 10 Feb 2023 19:27:16 -0800 Subject: [PATCH] cast: 'no_clear' --- .../scripts/commands/entity/CastCommand.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/CastCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/CastCommand.java index cd94b8c9e5..deca5c4a44 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/CastCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/CastCommand.java @@ -20,16 +20,16 @@ public class CastCommand extends AbstractCommand { public CastCommand() { setName("cast"); - setSyntax("cast [] (remove) (duration:) (amplifier:<#>) (|...) (no_ambient) (hide_particles) (no_icon)"); - setRequiredArguments(1, 8); + setSyntax("cast [] (remove) (duration:) (amplifier:<#>) (|...) (no_ambient) (hide_particles) (no_icon) (no_clear)"); + setRequiredArguments(1, 9); isProcedural = false; } // <--[command] // @Name Cast - // @Syntax cast [] (remove) (duration:) (amplifier:<#>) (|...) (no_ambient) (hide_particles) (no_icon) + // @Syntax cast [] (remove) (duration:) (amplifier:<#>) (|...) (no_ambient) (hide_particles) (no_icon) (no_clear) // @Required 1 - // @Maximum 8 + // @Maximum 9 // @Short Casts a potion effect to a list of entities. // @Synonyms Potion,Magic // @Group entity @@ -57,6 +57,8 @@ public CastCommand() { // // Optionally, specify "no_icon" to hide the effect icon in the corner of your screen. // + // Optionally use "no_clear" to prevent clearing any previous effect instance before adding the new one. + // // @Tags // ]> // @@ -94,6 +96,10 @@ else if (!scriptEntry.hasObject("ambient") && arg.matches("no_ambient")) { scriptEntry.addObject("ambient", new ElementTag(false)); } + else if (!scriptEntry.hasObject("no_clear") + && arg.matches("no_clear")) { + scriptEntry.addObject("no_clear", new ElementTag(true)); + } else if (!scriptEntry.hasObject("show_particles") && arg.matches("hide_particles")) { scriptEntry.addObject("show_particles", new ElementTag(false)); @@ -151,14 +157,15 @@ public void execute(ScriptEntry scriptEntry) { ElementTag showParticles = scriptEntry.getElement("show_particles"); ElementTag ambient = scriptEntry.getElement("ambient"); ElementTag showIcon = scriptEntry.getElement("show_icon"); + ElementTag noClear = scriptEntry.getElement("no_clear"); if (scriptEntry.dbCallShouldDebug()) { - Debug.report(scriptEntry, getName(), db("targets", entities), db("effect", effect.getName()), db("amplifier", amplifier), duration, ambient, showParticles, showIcon); + Debug.report(scriptEntry, getName(), db("targets", entities), db("effect", effect.getName()), db("amplifier", amplifier), duration, ambient, showParticles, showIcon, noClear); } boolean amb = ambient.asBoolean(); boolean showP = showParticles.asBoolean(); boolean icon = showIcon.asBoolean(); for (EntityTag entity : entities) { - if (entity.getLivingEntity().hasPotionEffect(effect)) { + if ((remove || noClear == null || !noClear.asBoolean()) && entity.getLivingEntity().hasPotionEffect(effect)) { entity.getLivingEntity().removePotionEffect(effect); } if (remove) {