From b8dd8ed2802910d2cadfc8cee6d6dd088dd26fec Mon Sep 17 00:00:00 2001 From: JasperLorelai Date: Tue, 16 Dec 2025 04:20:11 +0100 Subject: [PATCH 1/2] feat: Add missing particle config - Added "dragon-breath-power", "spell.color", "spell.power" ("particles" effect & "ParticleCloudSpell") - Added "sculk-charge-rotation", "shriek-delay" ("ParticleCloudSpell") --- .../effecttypes/ParticlesEffect.java | 17 ++++++++--- .../spells/targeted/ParticleCloudSpell.java | 18 +++++++++++- .../util/config/ConfigDataUtil.java | 29 +++++++++++++++++++ 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ParticlesEffect.java b/core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ParticlesEffect.java index 27f6bff4a..6f00ddab6 100644 --- a/core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ParticlesEffect.java +++ b/core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ParticlesEffect.java @@ -36,6 +36,7 @@ public class ParticlesEffect extends SpellEffect { protected ConfigData material; protected ConfigData blockData; protected ConfigData dustOptions; + protected ConfigData spellOptions; protected ConfigData dustTransition; protected ConfigData vibrationOffset; @@ -59,6 +60,7 @@ public class ParticlesEffect extends SpellEffect { protected ConfigData xSpread; protected ConfigData ySpread; protected ConfigData zSpread; + protected ConfigData dragonBreathPower; protected ConfigData sculkChargeRotation; protected ConfigData force; @@ -73,6 +75,7 @@ public void loadFromConfig(ConfigurationSection config) { blockData = ConfigDataUtil.getBlockData(config, "material", null); dustOptions = ConfigDataUtil.getDustOptions(config, "color", "size", new DustOptions(Color.RED, 1)); dustTransition = ConfigDataUtil.getDustTransition(config, "color", "to-color", "size", new DustTransition(Color.RED, Color.BLACK, 1)); + spellOptions = ConfigDataUtil.getSpellOptions(config, "spell.color", "spell.power", null); vibrationOffset = ConfigDataUtil.getVector(config, "vibration-offset", new Vector()); vibrationOrigin = ConfigDataUtil.getEnum(config, "vibration-origin", ParticlePosition.class, ParticlePosition.POSITION); @@ -91,12 +94,14 @@ public void loadFromConfig(ConfigurationSection config) { arrivalTime = ConfigDataUtil.getInteger(config, "arrival-time", -1); shriekDelay = ConfigDataUtil.getInteger(config, "shriek-delay", 0); + dragonBreathPower = ConfigDataUtil.getFloat(config, "dragon-breath-power", 1); + sculkChargeRotation = ConfigDataUtil.getFloat(config, "sculk-charge-rotation", 0); + speed = ConfigDataUtil.getFloat(config, "speed", 0.2f); ConfigData horizSpread = ConfigDataUtil.getFloat(config, "horiz-spread", 0.2f); xSpread = ConfigDataUtil.getFloat(config, "x-spread", horizSpread); zSpread = ConfigDataUtil.getFloat(config, "z-spread", horizSpread); - sculkChargeRotation = ConfigDataUtil.getFloat(config, "sculk-charge-rotation", 0); ConfigData vertSpread = ConfigDataUtil.getFloat(config, "vert-spread", 0.2f); ySpread = ConfigDataUtil.getFloat(config, "y-spread", vertSpread); @@ -209,12 +214,16 @@ protected Object getParticleData(@NotNull Particle particle, @Nullable Entity en if (type == BlockData.class) return blockData.get(data); if (type == DustOptions.class) return dustOptions.get(data); + if (type == Particle.Spell.class) return spellOptions.get(data); if (type == DustTransition.class) return dustTransition.get(data); - if (type == Float.class) return sculkChargeRotation.get(data); - if (type == Integer.class) return shriekDelay.get(data); if (type == Color.class) return argbColor.get(data); - return null; + return switch (particle) { + case SHRIEK -> shriekDelay.get(data); + case DRAGON_BREATH -> dragonBreathPower.get(data); + case SCULK_CHARGE -> sculkChargeRotation.get(data); + default -> null; + }; } protected Location getSpawnLocation(@NotNull Particle particle, @NotNull Location position, @NotNull SpellData data) { diff --git a/core/src/main/java/com/nisovin/magicspells/spells/targeted/ParticleCloudSpell.java b/core/src/main/java/com/nisovin/magicspells/spells/targeted/ParticleCloudSpell.java index cb4d6eb05..d89795dfd 100644 --- a/core/src/main/java/com/nisovin/magicspells/spells/targeted/ParticleCloudSpell.java +++ b/core/src/main/java/com/nisovin/magicspells/spells/targeted/ParticleCloudSpell.java @@ -36,11 +36,13 @@ public class ParticleCloudSpell extends TargetedSpell implements TargetedLocatio private final ConfigData item; private final ConfigData blockData; private final ConfigData dustOptions; + private final ConfigData spellOptions; private final ConfigData dustTransition; private final ConfigData particle; private final ConfigData waitTime; + private final ConfigData shriekDelay; private final ConfigData ticksDuration; private final ConfigData durationOnUse; private final ConfigData reapplicationDelay; @@ -48,6 +50,8 @@ public class ParticleCloudSpell extends TargetedSpell implements TargetedLocatio private final ConfigData radius; private final ConfigData radiusOnUse; private final ConfigData radiusPerTick; + private final ConfigData dragonBreathPower; + private final ConfigData sculkChargeRotation; private final ConfigData useGravity; private final ConfigData canTargetEntities; @@ -74,6 +78,7 @@ public ParticleCloudSpell(MagicConfig config, String spellName) { internalKey + "dust-transition.size", new DustTransition(Color.RED, Color.BLACK, 1) ); + spellOptions = ConfigDataUtil.getSpellOptions(config.getMainConfig(), internalKey + "spell.color", internalKey + "spell.power", null); ConfigData material = getConfigDataMaterial("material", null); if (material.isConstant()) { @@ -88,6 +93,11 @@ public ParticleCloudSpell(MagicConfig config, String spellName) { }; } + shriekDelay = getConfigDataInt("shriek-delay", 0); + + dragonBreathPower = getConfigDataFloat("dragon-breath-power", 1); + sculkChargeRotation = getConfigDataFloat("sculk-charge-rotation", 0); + ConfigData colorInt = getConfigDataInt("color", 0xFF0000); color = ConfigDataUtil.getARGBColor(config.getMainConfig(), internalKey + "argb-color", null) .orDefault(data -> Color.fromRGB(colorInt.get(data))); @@ -188,9 +198,15 @@ private Object getParticleData(@NotNull Particle particle, @NotNull SpellData da if (type == ItemStack.class) return item.get(data); if (type == BlockData.class) return blockData.get(data); if (type == DustOptions.class) return dustOptions.get(data); + if (type == Particle.Spell.class) return spellOptions.get(data); if (type == DustTransition.class) return dustTransition.get(data); - return null; + return switch (particle) { + case SHRIEK -> shriekDelay.get(data); + case DRAGON_BREATH -> dragonBreathPower.get(data); + case SCULK_CHARGE -> sculkChargeRotation.get(data); + default -> null; + }; } } diff --git a/core/src/main/java/com/nisovin/magicspells/util/config/ConfigDataUtil.java b/core/src/main/java/com/nisovin/magicspells/util/config/ConfigDataUtil.java index f976b3968..343a8490d 100644 --- a/core/src/main/java/com/nisovin/magicspells/util/config/ConfigDataUtil.java +++ b/core/src/main/java/com/nisovin/magicspells/util/config/ConfigDataUtil.java @@ -1151,6 +1151,35 @@ public boolean isConstant() { return data -> def; } + @NotNull + public static ConfigData getSpellOptions(@NotNull ConfigurationSection config, + @NotNull String colorPath, + @NotNull String powerPath, + @Nullable Particle.Spell def) { + ConfigData color = getColor(config, colorPath, def == null ? null : def.getColor()); + ConfigData power = def == null ? getFloat(config, powerPath) : getFloat(config, powerPath, def.getPower()); + + if (color.isConstant() && power.isConstant()) { + Color c = color.get(); + if (c == null) return data -> def; + + Float p = power.get(); + if (p == null) return data -> def; + + return data -> new Particle.Spell(c, p); + } + + return (VariableConfigData) data -> { + Color c = color.get(data); + if (c == null) return def; + + Float p = power.get(data); + if (p == null) return def; + + return new Particle.Spell(c, p); + }; + } + @NotNull public static ConfigData getDustOptions(@NotNull ConfigurationSection config, @NotNull String colorPath, From e773b4e98e287ca309051082b1d83354d245c209 Mon Sep 17 00:00:00 2001 From: JasperLorelai Date: Tue, 16 Dec 2025 04:32:14 +0100 Subject: [PATCH 2/2] feat: Extract "color" from "argb-color" --- .../spelleffects/effecttypes/ParticlesEffect.java | 13 +++++++++++-- .../spells/targeted/ParticleCloudSpell.java | 15 +++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ParticlesEffect.java b/core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ParticlesEffect.java index 6f00ddab6..5daf5d66c 100644 --- a/core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ParticlesEffect.java +++ b/core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ParticlesEffect.java @@ -32,7 +32,9 @@ public class ParticlesEffect extends SpellEffect { protected ConfigData particle; + protected ConfigData rgbColor; protected ConfigData argbColor; + protected ConfigData material; protected ConfigData blockData; protected ConfigData dustOptions; @@ -70,7 +72,9 @@ public class ParticlesEffect extends SpellEffect { public void loadFromConfig(ConfigurationSection config) { particle = ConfigDataUtil.getParticle(config, "particle-name", Particle.POOF); - argbColor = ConfigDataUtil.getARGBColor(config, "argb-color", null); + rgbColor = ConfigDataUtil.getColor(config, "color", null); + argbColor = ConfigDataUtil.getARGBColor(config, "argb-color", null).orDefault(rgbColor); + material = ConfigDataUtil.getMaterial(config, "material", null); blockData = ConfigDataUtil.getBlockData(config, "material", null); dustOptions = ConfigDataUtil.getDustOptions(config, "color", "size", new DustOptions(Color.RED, 1)); @@ -154,6 +158,12 @@ public Runnable playEffectLocation(Location location, SpellData data) { protected Object getParticleData(@NotNull Particle particle, @Nullable Entity entity, @NotNull Location location, @NotNull SpellData data) { Class type = particle.getDataType(); + if (type == Color.class) { + return particle == Particle.ENTITY_EFFECT ? + argbColor.get(data) : + rgbColor.get(data); + } + if (type == ItemStack.class) { Material material = this.material.get(data); return material == null ? null : new ItemStack(material); @@ -216,7 +226,6 @@ protected Object getParticleData(@NotNull Particle particle, @Nullable Entity en if (type == DustOptions.class) return dustOptions.get(data); if (type == Particle.Spell.class) return spellOptions.get(data); if (type == DustTransition.class) return dustTransition.get(data); - if (type == Color.class) return argbColor.get(data); return switch (particle) { case SHRIEK -> shriekDelay.get(data); diff --git a/core/src/main/java/com/nisovin/magicspells/spells/targeted/ParticleCloudSpell.java b/core/src/main/java/com/nisovin/magicspells/spells/targeted/ParticleCloudSpell.java index d89795dfd..66546bde0 100644 --- a/core/src/main/java/com/nisovin/magicspells/spells/targeted/ParticleCloudSpell.java +++ b/core/src/main/java/com/nisovin/magicspells/spells/targeted/ParticleCloudSpell.java @@ -32,7 +32,9 @@ public class ParticleCloudSpell extends TargetedSpell implements TargetedLocatio private final ConfigData customName; - private final ConfigData color; + private final ConfigData rgbColor; + private final ConfigData argbColor; + private final ConfigData item; private final ConfigData blockData; private final ConfigData dustOptions; @@ -99,8 +101,8 @@ public ParticleCloudSpell(MagicConfig config, String spellName) { sculkChargeRotation = getConfigDataFloat("sculk-charge-rotation", 0); ConfigData colorInt = getConfigDataInt("color", 0xFF0000); - color = ConfigDataUtil.getARGBColor(config.getMainConfig(), internalKey + "argb-color", null) - .orDefault(data -> Color.fromRGB(colorInt.get(data))); + rgbColor = getConfigDataColor("color", null).orDefault(data -> Color.fromRGB(colorInt.get(data))); + argbColor = ConfigDataUtil.getARGBColor(config.getMainConfig(), internalKey + "argb-color", null).orDefault(rgbColor); waitTime = getConfigDataInt("wait-time-ticks", 10); ticksDuration = getConfigDataInt("duration-ticks", 3 * TimeUtil.TICKS_PER_SECOND); @@ -194,13 +196,18 @@ private CastResult spawnCloud(SpellData data) { private Object getParticleData(@NotNull Particle particle, @NotNull SpellData data) { Class type = particle.getDataType(); - if (type == Color.class) return color.get(data); if (type == ItemStack.class) return item.get(data); if (type == BlockData.class) return blockData.get(data); if (type == DustOptions.class) return dustOptions.get(data); if (type == Particle.Spell.class) return spellOptions.get(data); if (type == DustTransition.class) return dustTransition.get(data); + if (type == Color.class) { + return particle == Particle.ENTITY_EFFECT ? + argbColor.get(data) : + rgbColor.get(data); + } + return switch (particle) { case SHRIEK -> shriekDelay.get(data); case DRAGON_BREATH -> dragonBreathPower.get(data);