From fbbd625ea1a2fd614e03fd9c7cbe77288d60f790 Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:49:25 +0100 Subject: [PATCH 1/9] Float, Integer, Color, TargetColor playeffect additions --- .../commands/world/PlayEffectCommand.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java index 2da37c6516..d95be262df 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java @@ -18,6 +18,7 @@ import com.denizenscript.denizencore.scripts.commands.AbstractCommand; import com.denizenscript.denizencore.utilities.CoreUtilities; import com.denizenscript.denizencore.utilities.debugging.Debug; +import org.bukkit.Color; import org.bukkit.Effect; import org.bukkit.Particle; import org.bukkit.Vibration; @@ -86,6 +87,10 @@ public PlayEffectCommand() { // - For BLOCK_MARKER, FALLING_DUST, BLOCK_CRACK, or BLOCK_DUST particles, the input is any valid MaterialTag, eg "stone". // - For VIBRATION, the input is || where origin is a LocationTag and destination is either LocationTag or EntityTag, for example "5s||" // - For ITEM_CRACK particles, the input is any valid ItemTag, eg "stick". + // - For TARGET_COLOR, the input is of format: |, for example "red|". Color input is any valid ColorTag object. + // - For COLOR, the input is any valid ColorTag. + // - For FLOAT, the input is any valid ElementTag(Decimal). + // - For INTEGER, the input is any valid ElementTag(Integer). // // Optionally specify a velocity vector for standard particles to move. Note that this ignores the 'data' input if used. // @@ -104,6 +109,24 @@ public PlayEffectCommand() { // @Usage // Use to play some effects at spawn. // - playeffect effect:FIREWORKS_SPARK at: visibility:100 quantity:375 data:0 offset:50.0 + // + // @Usage + // Use to spawn a cloud of rainbow-colored ENTITY_EFFECT particles around yourself. + // - foreach as:color: + // - playeffect effect:ENTITY_EFFECT at: quantity:25 special_data:<[color]> + // + // @Usage + // Use to shoot a laser in to the direction you're looking at. + // - playeffect effect:TRAIL at: quantity:100 offset:0 special_data:RED| + // + // @Usage + // Use to spawn a SCULK_CHARGE effect upside down. + // - playeffect effect:SCULK_CHARGE at: quantity:1 offset:0 special_data: + // + // @Usage + // Use to play a SHRIEK effect with a 5-second delay. + // - playeffect effect:SHRIEK at: quantity:1 special_data:100 + // // --> @Override @@ -345,6 +368,27 @@ else if (clazz == Vibration.class) { dataObject = new Vibration(origin, destObj, duration.getTicksAsInt()); } } + else if (clazz == Particle.TargetColor.class) { + ListTag dataList = ListTag.valueOf(special_data.asString(), scriptEntry.getContext()); + if (dataList.size() != 2) { + Debug.echoError("TargetColor special_data must have 2 list entries for particle: " + particleEffect.name()); + return; + } else { + ColorTag color = dataList.getObject(0).asType(ColorTag.class, scriptEntry.context); + LocationTag target = dataList.getObject(1).asType(LocationTag.class, scriptEntry.context); + dataObject = new Particle.TargetColor(target, BukkitColorExtensions.getColor(color)); + } + } + else if (clazz == Color.class) { + ColorTag color = ColorTag.valueOf(special_data.asString(), scriptEntry.context); + dataObject = BukkitColorExtensions.getColor(color); + } + else if (clazz == Integer.class) { + dataObject = special_data.asInt(); + } + else if (clazz == Float.class) { + dataObject = special_data.asFloat(); + } else { Debug.echoError("Unknown particle data type: " + clazz.getCanonicalName() + " for particle: " + particleEffect.name()); return; From ffc45fbe5be68c25ff1943dbb41f3c40fb4d4037 Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:44:56 +0100 Subject: [PATCH 2/9] update meta --- .../scripts/commands/world/PlayEffectCommand.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java index d95be262df..004e42ac62 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java @@ -85,12 +85,11 @@ public PlayEffectCommand() { // - For REDSTONE particles, the input is of format: |, for example: "1.2|red". Color input is any valid ColorTag object. // - For DUST_COLOR_TRANSITION particles, the input is of format ||, for example "1.2|red|blue". Color input is any valid ColorTag object. // - For BLOCK_MARKER, FALLING_DUST, BLOCK_CRACK, or BLOCK_DUST particles, the input is any valid MaterialTag, eg "stone". - // - For VIBRATION, the input is || where origin is a LocationTag and destination is either LocationTag or EntityTag, for example "5s||" + // - For VIBRATION particles, the input is || where origin is a LocationTag and destination is either LocationTag or EntityTag, for example "5s||" // - For ITEM_CRACK particles, the input is any valid ItemTag, eg "stick". - // - For TARGET_COLOR, the input is of format: |, for example "red|". Color input is any valid ColorTag object. - // - For COLOR, the input is any valid ColorTag. - // - For FLOAT, the input is any valid ElementTag(Decimal). - // - For INTEGER, the input is any valid ElementTag(Integer). + // - For TRAIL particles, the input is of format: |, for example "red|". Color input is any valid ColorTag object. + // - For ENTITY_EFFECT particles, the input is any valid ColorTag. + // - For SHRIEK and SCULK_CHARGE particles, the input is any valid number. // // Optionally specify a velocity vector for standard particles to move. Note that this ignores the 'data' input if used. // From 916e4b139d2403513d748273d6a5f66a98a77ada Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:43:38 +0100 Subject: [PATCH 3/9] fix format --- .../denizen/scripts/commands/world/PlayEffectCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java index 004e42ac62..3b3fc0e2f2 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java @@ -372,7 +372,8 @@ else if (clazz == Particle.TargetColor.class) { if (dataList.size() != 2) { Debug.echoError("TargetColor special_data must have 2 list entries for particle: " + particleEffect.name()); return; - } else { + } + else { ColorTag color = dataList.getObject(0).asType(ColorTag.class, scriptEntry.context); LocationTag target = dataList.getObject(1).asType(LocationTag.class, scriptEntry.context); dataObject = new Particle.TargetColor(target, BukkitColorExtensions.getColor(color)); From 42202a8e15f7e3044d518ba547364f7cace2c7a2 Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Fri, 27 Dec 2024 16:19:19 +0100 Subject: [PATCH 4/9] 1.21.4 changes --- .../commands/world/PlayEffectCommand.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java index 3b3fc0e2f2..8ed43b8b67 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java @@ -87,9 +87,10 @@ public PlayEffectCommand() { // - For BLOCK_MARKER, FALLING_DUST, BLOCK_CRACK, or BLOCK_DUST particles, the input is any valid MaterialTag, eg "stone". // - For VIBRATION particles, the input is || where origin is a LocationTag and destination is either LocationTag or EntityTag, for example "5s||" // - For ITEM_CRACK particles, the input is any valid ItemTag, eg "stick". - // - For TRAIL particles, the input is of format: |, for example "red|". Color input is any valid ColorTag object. + // - For TRAIL particles, the input is ||, for example "red||20s". Color input is any valid ColorTag object. // - For ENTITY_EFFECT particles, the input is any valid ColorTag. - // - For SHRIEK and SCULK_CHARGE particles, the input is any valid number. + // - For SHRIEK particles, the input is any valid DurationTag. + // - For SCULK_CHARGE particles, the input is any valid Number. // // Optionally specify a velocity vector for standard particles to move. Note that this ignores the 'data' input if used. // @@ -115,8 +116,10 @@ public PlayEffectCommand() { // - playeffect effect:ENTITY_EFFECT at: quantity:25 special_data:<[color]> // // @Usage - // Use to shoot a laser in to the direction you're looking at. - // - playeffect effect:TRAIL at: quantity:100 offset:0 special_data:RED| + // Use to shoot particles in to the direction you're looking at. + // - repeat 10: + // - playeffect effect:TRAIL at: quantity:1 offset:0 special_data:RED||5s + // - wait 1t // // @Usage // Use to spawn a SCULK_CHARGE effect upside down. @@ -124,7 +127,7 @@ public PlayEffectCommand() { // // @Usage // Use to play a SHRIEK effect with a 5-second delay. - // - playeffect effect:SHRIEK at: quantity:1 special_data:100 + // - playeffect effect:SHRIEK at: quantity:1 special_data:5s // // --> @@ -367,16 +370,17 @@ else if (clazz == Vibration.class) { dataObject = new Vibration(origin, destObj, duration.getTicksAsInt()); } } - else if (clazz == Particle.TargetColor.class) { + else if (clazz == Particle.Trail.class) { ListTag dataList = ListTag.valueOf(special_data.asString(), scriptEntry.getContext()); - if (dataList.size() != 2) { - Debug.echoError("TargetColor special_data must have 2 list entries for particle: " + particleEffect.name()); + if (dataList.size() != 3) { + Debug.echoError("Trail special_data must have 3 list entries for particle: " + particleEffect.name()); return; } else { ColorTag color = dataList.getObject(0).asType(ColorTag.class, scriptEntry.context); LocationTag target = dataList.getObject(1).asType(LocationTag.class, scriptEntry.context); - dataObject = new Particle.TargetColor(target, BukkitColorExtensions.getColor(color)); + DurationTag duration = dataList.getObject(2).asType(DurationTag.class, scriptEntry.context); + dataObject = new Particle.Trail(target, BukkitColorExtensions.getColor(color), duration.getTicksAsInt()); } } else if (clazz == Color.class) { @@ -384,7 +388,7 @@ else if (clazz == Color.class) { dataObject = BukkitColorExtensions.getColor(color); } else if (clazz == Integer.class) { - dataObject = special_data.asInt(); + dataObject = special_data.asType(DurationTag.class, scriptEntry.context).getTicksAsInt(); } else if (clazz == Float.class) { dataObject = special_data.asFloat(); From 9a61c647db7ba7692dc2fb3d1a34f04cff15f6d0 Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Sat, 4 Jan 2025 18:11:42 +0100 Subject: [PATCH 5/9] playeffect cmd part 1 --- .../commands/world/PlayEffectCommand.java | 246 ++++++++++++------ .../utilities/BukkitImplDeprecations.java | 2 + 2 files changed, 168 insertions(+), 80 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java index 8ed43b8b67..88f637beab 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java @@ -10,18 +10,12 @@ import com.denizenscript.denizencore.exceptions.InvalidArgumentsException; import com.denizenscript.denizencore.objects.Argument; import com.denizenscript.denizencore.objects.ObjectTag; -import com.denizenscript.denizencore.objects.core.ColorTag; -import com.denizenscript.denizencore.objects.core.DurationTag; -import com.denizenscript.denizencore.objects.core.ElementTag; -import com.denizenscript.denizencore.objects.core.ListTag; +import com.denizenscript.denizencore.objects.core.*; import com.denizenscript.denizencore.scripts.ScriptEntry; import com.denizenscript.denizencore.scripts.commands.AbstractCommand; import com.denizenscript.denizencore.utilities.CoreUtilities; import com.denizenscript.denizencore.utilities.debugging.Debug; -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.Particle; -import org.bukkit.Vibration; +import org.bukkit.*; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -81,16 +75,16 @@ public PlayEffectCommand() { // The distinction is in whether you include the (now expected to use) "at:" prefix on your location argument. // If you do not have this prefix, the system will assume your command is older, and will apply the 1-block height offset. // - // Some particles will require input to the "special_data" argument. The data input is unique per particle. - // - For REDSTONE particles, the input is of format: |, for example: "1.2|red". Color input is any valid ColorTag object. - // - For DUST_COLOR_TRANSITION particles, the input is of format ||, for example "1.2|red|blue". Color input is any valid ColorTag object. - // - For BLOCK_MARKER, FALLING_DUST, BLOCK_CRACK, or BLOCK_DUST particles, the input is any valid MaterialTag, eg "stone". - // - For VIBRATION particles, the input is || where origin is a LocationTag and destination is either LocationTag or EntityTag, for example "5s||" - // - For ITEM_CRACK particles, the input is any valid ItemTag, eg "stick". - // - For TRAIL particles, the input is ||, for example "red||20s". Color input is any valid ColorTag object. - // - For ENTITY_EFFECT particles, the input is any valid ColorTag. - // - For SHRIEK particles, the input is any valid DurationTag. - // - For SCULK_CHARGE particles, the input is any valid Number. + // Some particles will require input to the "special_data" argument. The data input is a MapTag with different keys per particle. + // - For REDSTONE particles, the input is of format [size=;color=], e.g. "[size=1.2;color=red]". + // - For DUST_COLOR_TRANSITION particles, the input is of format [size=;from=;to=], e.g "[size=1.2;from=red;to=blue]". + // - For BLOCK_MARKER, FALLING_DUST, BLOCK_CRACK, or BLOCK_DUST particles, the input is of format [material=], eg [material=stone] + // - For VIBRATION particles, the input is of format [origin=;destination=;duration=], for example: [origin=;destination=;duration=5s] + // - For ITEM_CRACK particles, the input is of format [item=], eg "[item=stick]". + // - For TRAIL particles, the input is of format [color=;target=;duration=], eg "[color=red;target=;duration=20s]". + // - For ENTITY_EFFECT particles, the input is of format [color=], eg "[color=green]". + // - For SHRIEK particles, the input is of format [duration=], eg "[duration=1m]". + // - For SCULK_CHARGE particles, the input is of format [radians=], eg "[radians=]". // // Optionally specify a velocity vector for standard particles to move. Note that this ignores the 'data' input if used. // @@ -113,21 +107,21 @@ public PlayEffectCommand() { // @Usage // Use to spawn a cloud of rainbow-colored ENTITY_EFFECT particles around yourself. // - foreach as:color: - // - playeffect effect:ENTITY_EFFECT at: quantity:25 special_data:<[color]> + // - playeffect effect:ENTITY_EFFECT at: quantity:25 special_data:[color=<[color]>] // // @Usage // Use to shoot particles in to the direction you're looking at. // - repeat 10: - // - playeffect effect:TRAIL at: quantity:1 offset:0 special_data:RED||5s + // - playeffect effect:TRAIL at: quantity:1 offset:0 special_data:[color=RED;target=;duration=5s] // - wait 1t // // @Usage // Use to spawn a SCULK_CHARGE effect upside down. - // - playeffect effect:SCULK_CHARGE at: quantity:1 offset:0 special_data: + // - playeffect effect:SCULK_CHARGE at: quantity:1 offset:0 special_data:[radians=] // // @Usage // Use to play a SHRIEK effect with a 5-second delay. - // - playeffect effect:SHRIEK at: quantity:1 special_data:5s + // - playeffect effect:SHRIEK at: quantity:1 special_data:[duration=5s] // // --> @@ -317,86 +311,178 @@ else if (particleEffect != null) { Debug.echoError("Missing required special data for particle: " + particleEffect.name()); return; } - else if (clazz == Particle.DustOptions.class) { + MapTag dataMap = MapTag.valueOf(special_data.asString(), scriptEntry.getContext()); + if (dataMap == null) { ListTag dataList = ListTag.valueOf(special_data.asString(), scriptEntry.getContext()); - if (dataList.size() != 2) { - Debug.echoError("DustOptions special_data must have 2 list entries for particle: " + particleEffect.name()); - return; - } - else { + if (clazz == Particle.DustOptions.class) { + if (dataList.size() != 2) { + Debug.echoError("DustOptions special_data must have 2 list entries for particle: " + particleEffect.name()); + return; + } float size = Float.parseFloat(dataList.get(0)); ColorTag color = ColorTag.valueOf(dataList.get(1), scriptEntry.context); dataObject = new Particle.DustOptions(BukkitColorExtensions.getColor(color), size); } - } - else if (clazz == BlockData.class) { - MaterialTag blockMaterial = MaterialTag.valueOf(special_data.asString(), scriptEntry.getContext()); - dataObject = blockMaterial.getModernData(); - } - else if (clazz == ItemStack.class) { - ItemTag itemType = ItemTag.valueOf(special_data.asString(), scriptEntry.getContext()); - dataObject = itemType.getItemStack(); - } - else if (clazz == Particle.DustTransition.class) { - ListTag dataList = ListTag.valueOf(special_data.asString(), scriptEntry.getContext()); - if (dataList.size() != 3) { - Debug.echoError("DustTransition special_data must have 3 list entries for particle: " + particleEffect.name()); - return; + else if (clazz == BlockData.class) { + MaterialTag blockMaterial = MaterialTag.valueOf(special_data.asString(), scriptEntry.getContext()); + dataObject = blockMaterial.getModernData(); + } + else if (clazz == ItemStack.class) { + ItemTag itemType = ItemTag.valueOf(special_data.asString(), scriptEntry.getContext()); + dataObject = itemType.getItemStack(); + } + else if (clazz == Particle.DustTransition.class) { + if (dataList.size() != 3) { + Debug.echoError("DustTransition special_data must have 3 list entries for particle: " + particleEffect.name()); + return; + } + else { + float size = Float.parseFloat(dataList.get(0)); + ColorTag fromColor = ColorTag.valueOf(dataList.get(1), scriptEntry.context); + ColorTag toColor = ColorTag.valueOf(dataList.get(2), scriptEntry.context); + dataObject = new Particle.DustTransition(BukkitColorExtensions.getColor(fromColor), BukkitColorExtensions.getColor(toColor), size); + } + } + else if (clazz == Vibration.class) { + if (dataList.size() != 3) { + Debug.echoError("Vibration special_data must have 3 list entries for particle: " + particleEffect.name()); + return; + } + else { + DurationTag duration = dataList.getObject(0).asType(DurationTag.class, scriptEntry.context); + LocationTag origin = dataList.getObject(1).asType(LocationTag.class, scriptEntry.context); + ObjectTag destination = dataList.getObject(2); + Vibration.Destination destObj; + if (destination.shouldBeType(EntityTag.class)) { + destObj = new Vibration.Destination.EntityDestination(destination.asType(EntityTag.class, scriptEntry.context).getBukkitEntity()); + } + else { + destObj = new Vibration.Destination.BlockDestination(destination.asType(LocationTag.class, scriptEntry.context)); + } + dataObject = new Vibration(origin, destObj, duration.getTicksAsInt()); + } } else { - float size = Float.parseFloat(dataList.get(0)); - ColorTag fromColor = ColorTag.valueOf(dataList.get(1), scriptEntry.context); - ColorTag toColor = ColorTag.valueOf(dataList.get(2), scriptEntry.context); - dataObject = new Particle.DustTransition(BukkitColorExtensions.getColor(fromColor), BukkitColorExtensions.getColor(toColor), size); + Debug.echoError("Unknown particle data type: " + clazz.getCanonicalName() + " for particle: " + particleEffect.name() + ". Are you sure it exists and are not using a legacy format?"); + return; } } - else if (clazz == Vibration.class) { - ListTag dataList = ListTag.valueOf(special_data.asString(), scriptEntry.getContext()); - if (dataList.size() != 3) { - Debug.echoError("Vibration special_data must have 3 list entries for particle: " + particleEffect.name()); - return; + else { + if (clazz == Particle.DustOptions.class) { + ElementTag size = dataMap.getObjectAs("size", ElementTag.class, scriptEntry.context); + if (size == null || !size.isFloat()) { + Debug.echoError("special_data input must have a 'size' key with a valid number."); + return; + } + ColorTag color = dataMap.getObjectAs("color", ColorTag.class, scriptEntry.context); + if (color == null) { + Debug.echoError("special_data input must have a 'color' key with a valid ColorTag"); + return; + } + dataObject = new Particle.DustOptions(BukkitColorExtensions.getColor(color), size.asFloat()); } - else { - DurationTag duration = dataList.getObject(0).asType(DurationTag.class, scriptEntry.context); - LocationTag origin = dataList.getObject(1).asType(LocationTag.class, scriptEntry.context); - ObjectTag destination = dataList.getObject(2); + else if (clazz == BlockData.class) { + MaterialTag blockMaterial = dataMap.getObjectAs("material", MaterialTag.class, scriptEntry.context); + if (blockMaterial == null) { + Debug.echoError("special_data input must have a 'material' key with a valid MaterialTag, for particle: " + particleEffect.name()); + return; + } + dataObject = blockMaterial.getModernData(); + } + else if (clazz == ItemStack.class) { + ItemTag itemType = dataMap.getObjectAs("item", ItemTag.class, scriptEntry.context); + if (itemType == null) { + Debug.echoError("special_data input must have a 'item' key with a valid ItemTag, for particle: " + particleEffect.name()); + return; + } + dataObject = itemType.getItemStack(); + } + else if (clazz == Particle.DustTransition.class) { + ElementTag size = dataMap.getObjectAs("size", ElementTag.class, scriptEntry.context); + if (size == null || !size.isFloat()) { + Debug.echoError("special_data input must have a 'size' key with a valid number."); + return; + } + ColorTag fromColor = dataMap.getObjectAs("from", ColorTag.class, scriptEntry.context); + ColorTag toColor = dataMap.getObjectAs("to", ColorTag.class, scriptEntry.context); + if (fromColor == null || toColor == null) { + Debug.echoError("special_data input must have a 'to' and 'size' key with a valid ColorTag."); + return; + } + dataObject = new Particle.DustTransition(BukkitColorExtensions.getColor(fromColor), BukkitColorExtensions.getColor(toColor), size.asFloat()); + } + else if (clazz == Vibration.class) { + DurationTag duration = dataMap.getObjectAs("duration", DurationTag.class, scriptEntry.context); + if (duration == null) { + Debug.echoError("special_data input must have a 'duration' key with a valid LocationTag, for particle: " + particleEffect.name()); + return; + } + LocationTag origin = dataMap.getObjectAs("origin", LocationTag.class, scriptEntry.context); + if (origin == null) { + Debug.echoError("special_data input must have a 'origin' key with a valid LocationTag, for particle: " + particleEffect.name()); + return; + } + ObjectTag destination = dataMap.getObjectAs("destination", ObjectTag.class, scriptEntry.context); Vibration.Destination destObj; if (destination.shouldBeType(EntityTag.class)) { destObj = new Vibration.Destination.EntityDestination(destination.asType(EntityTag.class, scriptEntry.context).getBukkitEntity()); } - else { + else if (destination.shouldBeType(LocationTag.class)){ destObj = new Vibration.Destination.BlockDestination(destination.asType(LocationTag.class, scriptEntry.context)); } + else { + Debug.echoError("special_data input must have a 'destination' key with a valid LocationTag or EntityTag, for particle: " + particleEffect.name()); + return; + } dataObject = new Vibration(origin, destObj, duration.getTicksAsInt()); } - } - else if (clazz == Particle.Trail.class) { - ListTag dataList = ListTag.valueOf(special_data.asString(), scriptEntry.getContext()); - if (dataList.size() != 3) { - Debug.echoError("Trail special_data must have 3 list entries for particle: " + particleEffect.name()); - return; + else if (clazz == Particle.Trail.class) { + ColorTag color = dataMap.getObjectAs("color", ColorTag.class, scriptEntry.context); + if (color == null) { + Debug.echoError("special_data input must have a 'color' key with a valid ColorTag, for particle: " + particleEffect.name()); + return; + } + LocationTag target = dataMap.getObjectAs("target", LocationTag.class, scriptEntry.context); + if (target == null) { + Debug.echoError("special_data input must have a 'target' key with a valid LocationTag, for particle: " + particleEffect.name()); + return; + } + DurationTag duration = dataMap.getObjectAs("duration", DurationTag.class, scriptEntry.context); + if (duration == null) { + Debug.echoError("special_data input must have a 'duration' key with a valid DurationTag, for particle: " + particleEffect.name()); + return; + } + dataObject = new Particle.Trail(target, BukkitColorExtensions.getColor(color), duration.getTicksAsInt()); + } + else if (clazz == Color.class) { + ColorTag color = dataMap.getObjectAs("color", ColorTag.class, scriptEntry.context); + if (!dataMap.getObject("color").canBeType(ColorTag.class)) { + Debug.echoError("special_data input must have a 'color' key with a valid ColorTag, for particle: " + particleEffect.name()); + return; + } + dataObject = BukkitColorExtensions.getColor(color); + } + else if (clazz == Integer.class) { + DurationTag duration = dataMap.getObjectAs("duration", DurationTag.class, scriptEntry.context); + if (duration == null) { + Debug.echoError("special_data input must have a 'duration' key with a valid DurationTag, for particle: " + particleEffect.name()); + return; + } + dataObject = duration.getTicksAsInt(); + } + else if (clazz == Float.class) { + ElementTag radians = dataMap.getObjectAs("radians", ElementTag.class, scriptEntry.context); + if (radians == null) { + Debug.echoError("special_data input must have a 'radians' key with a valid number, for particle: " + particleEffect.name()); + return; + } + dataObject = radians.asFloat(); } else { - ColorTag color = dataList.getObject(0).asType(ColorTag.class, scriptEntry.context); - LocationTag target = dataList.getObject(1).asType(LocationTag.class, scriptEntry.context); - DurationTag duration = dataList.getObject(2).asType(DurationTag.class, scriptEntry.context); - dataObject = new Particle.Trail(target, BukkitColorExtensions.getColor(color), duration.getTicksAsInt()); + Debug.echoError("Unknown particle data type: " + clazz.getCanonicalName() + " for particle: " + particleEffect.name()); + return; } } - else if (clazz == Color.class) { - ColorTag color = ColorTag.valueOf(special_data.asString(), scriptEntry.context); - dataObject = BukkitColorExtensions.getColor(color); - } - else if (clazz == Integer.class) { - dataObject = special_data.asType(DurationTag.class, scriptEntry.context).getTicksAsInt(); - } - else if (clazz == Float.class) { - dataObject = special_data.asFloat(); - } - else { - Debug.echoError("Unknown particle data type: " + clazz.getCanonicalName() + " for particle: " + particleEffect.name()); - return; - } } else if (special_data != null) { Debug.echoError("Particles of type '" + particleEffect.name() + "' cannot take special_data as input."); diff --git a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java index 7be2570b99..62abf91e4f 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java +++ b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java @@ -344,6 +344,8 @@ public class BukkitImplDeprecations { // Bad candidate for bumping, targets extremely commonly used naming, some of which may be hard to remove (eg stored in flag data). public static Warning oldSpigotNames = new FutureWarning("oldSpigotNames", "Several features (particles, entities, etc.) had alternative naming added by Spigot, which are now deprecated in favor of the official Minecraft naming; see relevant feature's meta docs for more information."); + // Added 2025/01/04 + public static Warning playEffectListInput = new FutureWarning("playEffectListInput", "List input in playeffect command is now deprecated. Please use a MapTag instead."); // ==================== PAST deprecations of things that are already gone but still have a warning left behind ==================== // Removed upstream 2023/10/29 without warning. From 151c7f1c1fa045e2ceeb3e68ae388fcd98daa20f Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Sat, 4 Jan 2025 19:25:16 +0100 Subject: [PATCH 6/9] playeffect cmd part 2 --- .../commands/world/PlayEffectCommand.java | 17 +++++++++-------- .../utilities/BukkitImplDeprecations.java | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java index 88f637beab..70b4039279 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java @@ -76,15 +76,15 @@ public PlayEffectCommand() { // If you do not have this prefix, the system will assume your command is older, and will apply the 1-block height offset. // // Some particles will require input to the "special_data" argument. The data input is a MapTag with different keys per particle. - // - For REDSTONE particles, the input is of format [size=;color=], e.g. "[size=1.2;color=red]". + // - For DUST particles, the input is of format [size=;color=], e.g. "[size=1.2;color=red]". // - For DUST_COLOR_TRANSITION particles, the input is of format [size=;from=;to=], e.g "[size=1.2;from=red;to=blue]". - // - For BLOCK_MARKER, FALLING_DUST, BLOCK_CRACK, or BLOCK_DUST particles, the input is of format [material=], eg [material=stone] + // - For BLOCK, BLOCK_CRUMBLE, BLOCK_MARKER, DUST_PILLAR, or FALLING_DUST particles, the input is of format [material=], e.g. [material=stone] // - For VIBRATION particles, the input is of format [origin=;destination=;duration=], for example: [origin=;destination=;duration=5s] - // - For ITEM_CRACK particles, the input is of format [item=], eg "[item=stick]". - // - For TRAIL particles, the input is of format [color=;target=;duration=], eg "[color=red;target=;duration=20s]". - // - For ENTITY_EFFECT particles, the input is of format [color=], eg "[color=green]". - // - For SHRIEK particles, the input is of format [duration=], eg "[duration=1m]". - // - For SCULK_CHARGE particles, the input is of format [radians=], eg "[radians=]". + // - For ITEM particles, the input is of format [item=], e.g. "[item=stick]". + // - For TRAIL particles, the input is of format [color=;target=;duration=], e.g. "[color=red;target=;duration=20s]". + // - For ENTITY_EFFECT particles, the input is of format [color=], e.g. "[color=green]". + // - For SHRIEK particles, the input is of format [duration=], e.g. "[duration=1m]". + // - For SCULK_CHARGE particles, the input is of format [radians=], e.g. "[radians=]". // // Optionally specify a velocity vector for standard particles to move. Note that this ignores the 'data' input if used. // @@ -112,7 +112,7 @@ public PlayEffectCommand() { // @Usage // Use to shoot particles in to the direction you're looking at. // - repeat 10: - // - playeffect effect:TRAIL at: quantity:1 offset:0 special_data:[color=RED;target=;duration=5s] + // - playeffect effect:TRAIL at: quantity:1 offset:0 special_data:[color=red;target=;duration=5s] // - wait 1t // // @Usage @@ -314,6 +314,7 @@ else if (particleEffect != null) { MapTag dataMap = MapTag.valueOf(special_data.asString(), scriptEntry.getContext()); if (dataMap == null) { ListTag dataList = ListTag.valueOf(special_data.asString(), scriptEntry.getContext()); + BukkitImplDeprecations.playEffectListInput.warn(scriptEntry.getContext()); if (clazz == Particle.DustOptions.class) { if (dataList.size() != 2) { Debug.echoError("DustOptions special_data must have 2 list entries for particle: " + particleEffect.name()); diff --git a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java index 62abf91e4f..3134c8c3ec 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java +++ b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java @@ -345,7 +345,8 @@ public class BukkitImplDeprecations { public static Warning oldSpigotNames = new FutureWarning("oldSpigotNames", "Several features (particles, entities, etc.) had alternative naming added by Spigot, which are now deprecated in favor of the official Minecraft naming; see relevant feature's meta docs for more information."); // Added 2025/01/04 - public static Warning playEffectListInput = new FutureWarning("playEffectListInput", "List input in playeffect command is now deprecated. Please use a MapTag instead."); + public static Warning playEffectListInput = new FutureWarning("playEffectListInput", "List input in playeffect command's special_data argument is now deprecated. Please use a MapTag instead."); + // ==================== PAST deprecations of things that are already gone but still have a warning left behind ==================== // Removed upstream 2023/10/29 without warning. From 2446ee60d59dd0917c65c9298eceabdd443080fe Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Sat, 4 Jan 2025 19:28:55 +0100 Subject: [PATCH 7/9] make also a part 3 --- .../denizen/scripts/commands/world/PlayEffectCommand.java | 2 +- .../denizen/utilities/BukkitImplDeprecations.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java index 70b4039279..392443750c 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java @@ -314,7 +314,7 @@ else if (particleEffect != null) { MapTag dataMap = MapTag.valueOf(special_data.asString(), scriptEntry.getContext()); if (dataMap == null) { ListTag dataList = ListTag.valueOf(special_data.asString(), scriptEntry.getContext()); - BukkitImplDeprecations.playEffectListInput.warn(scriptEntry.getContext()); + BukkitImplDeprecations.playEffectSpecialDataListInput.warn(scriptEntry.getContext()); if (clazz == Particle.DustOptions.class) { if (dataList.size() != 2) { Debug.echoError("DustOptions special_data must have 2 list entries for particle: " + particleEffect.name()); diff --git a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java index 3134c8c3ec..e668b4f72f 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java +++ b/plugin/src/main/java/com/denizenscript/denizen/utilities/BukkitImplDeprecations.java @@ -345,8 +345,8 @@ public class BukkitImplDeprecations { public static Warning oldSpigotNames = new FutureWarning("oldSpigotNames", "Several features (particles, entities, etc.) had alternative naming added by Spigot, which are now deprecated in favor of the official Minecraft naming; see relevant feature's meta docs for more information."); // Added 2025/01/04 - public static Warning playEffectListInput = new FutureWarning("playEffectListInput", "List input in playeffect command's special_data argument is now deprecated. Please use a MapTag instead."); - + public static Warning playEffectSpecialDataListInput = new FutureWarning("playEffectSpecialDataListInput", "List input for the special_data argument in playeffect command is now deprecated. Please use a MapTag instead."); + // ==================== PAST deprecations of things that are already gone but still have a warning left behind ==================== // Removed upstream 2023/10/29 without warning. From e072dfb2b74ca2250bc07f23a162fc5891fe358a Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Wed, 15 Jan 2025 22:37:15 +0100 Subject: [PATCH 8/9] this is the final part --- .../scripts/commands/world/PlayEffectCommand.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java index 392443750c..c2ee706124 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java @@ -372,12 +372,12 @@ else if (clazz == Vibration.class) { if (clazz == Particle.DustOptions.class) { ElementTag size = dataMap.getObjectAs("size", ElementTag.class, scriptEntry.context); if (size == null || !size.isFloat()) { - Debug.echoError("special_data input must have a 'size' key with a valid number."); + Debug.echoError("special_data input must have a 'size' key with a valid number, for particle " + particleEffect.name()); return; } ColorTag color = dataMap.getObjectAs("color", ColorTag.class, scriptEntry.context); if (color == null) { - Debug.echoError("special_data input must have a 'color' key with a valid ColorTag"); + Debug.echoError("special_data input must have a 'color' key with a valid ColorTag, for particle: " + particleEffect.name()); return; } dataObject = new Particle.DustOptions(BukkitColorExtensions.getColor(color), size.asFloat()); @@ -401,13 +401,13 @@ else if (clazz == ItemStack.class) { else if (clazz == Particle.DustTransition.class) { ElementTag size = dataMap.getObjectAs("size", ElementTag.class, scriptEntry.context); if (size == null || !size.isFloat()) { - Debug.echoError("special_data input must have a 'size' key with a valid number."); + Debug.echoError("special_data input must have a 'size' key with a valid number, for particle: " + particleEffect.name()); return; } ColorTag fromColor = dataMap.getObjectAs("from", ColorTag.class, scriptEntry.context); ColorTag toColor = dataMap.getObjectAs("to", ColorTag.class, scriptEntry.context); if (fromColor == null || toColor == null) { - Debug.echoError("special_data input must have a 'to' and 'size' key with a valid ColorTag."); + Debug.echoError("special_data input must have a 'to' and 'size' key with a valid ColorTag, for particle: " + particleEffect.name()); return; } dataObject = new Particle.DustTransition(BukkitColorExtensions.getColor(fromColor), BukkitColorExtensions.getColor(toColor), size.asFloat()); @@ -473,7 +473,7 @@ else if (clazz == Integer.class) { } else if (clazz == Float.class) { ElementTag radians = dataMap.getObjectAs("radians", ElementTag.class, scriptEntry.context); - if (radians == null) { + if (radians == null || !radians.isFloat()) { Debug.echoError("special_data input must have a 'radians' key with a valid number, for particle: " + particleEffect.name()); return; } From 5456b245676cea72a5845c0299d26d12d24f4bc7 Mon Sep 17 00:00:00 2001 From: Hydroxycobalamin <54799651+Hydroxycobalamin@users.noreply.github.com> Date: Wed, 15 Jan 2025 22:52:56 +0100 Subject: [PATCH 9/9] turn special_data into a map --- .../denizen/scripts/commands/world/PlayEffectCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java index c2ee706124..5c0a842e80 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/PlayEffectCommand.java @@ -35,7 +35,7 @@ public class PlayEffectCommand extends AbstractCommand { public PlayEffectCommand() { setName("playeffect"); - setSyntax("playeffect [effect:] [at:|...] (data:<#.#>) (special_data:) (visibility:<#.#>) (quantity:<#>) (offset:<#.#>,<#.#>,<#.#>) (targets:|...) (velocity:)"); + setSyntax("playeffect [effect:] [at:|...] (data:<#.#>) (special_data:) (visibility:<#.#>) (quantity:<#>) (offset:<#.#>,<#.#>,<#.#>) (targets:|...) (velocity:)"); setRequiredArguments(2, 8); isProcedural = false; } @@ -54,7 +54,7 @@ public PlayEffectCommand() { // <--[command] // @Name PlayEffect - // @Syntax playeffect [effect:] [at:|...] (data:<#.#>) (special_data:) (visibility:<#.#>) (quantity:<#>) (offset:<#.#>,<#.#>,<#.#>) (targets:|...) (velocity:) + // @Syntax playeffect [effect:] [at:|...] (data:<#.#>) (special_data:) (visibility:<#.#>) (quantity:<#>) (offset:<#.#>,<#.#>,<#.#>) (targets:|...) (velocity:) // @Required 2 // @Maximum 8 // @Short Plays a visible or audible effect at the location.