Skip to content

Commit 68026c1

Browse files
committed
feat: Extract "color" from "argb-color"
1 parent a6a0fdd commit 68026c1

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ParticlesEffect.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public class ParticlesEffect extends SpellEffect {
3232

3333
protected ConfigData<Particle> particle;
3434

35+
protected ConfigData<Color> rgbColor;
3536
protected ConfigData<Color> argbColor;
37+
3638
protected ConfigData<Material> material;
3739
protected ConfigData<BlockData> blockData;
3840
protected ConfigData<DustOptions> dustOptions;
@@ -70,7 +72,9 @@ public class ParticlesEffect extends SpellEffect {
7072
public void loadFromConfig(ConfigurationSection config) {
7173
particle = ConfigDataUtil.getParticle(config, "particle-name", Particle.POOF);
7274

73-
argbColor = ConfigDataUtil.getARGBColor(config, "argb-color", null);
75+
rgbColor = ConfigDataUtil.getColor(config, "color", null);
76+
argbColor = ConfigDataUtil.getARGBColor(config, "argb-color", null).orDefault(rgbColor);
77+
7478
material = ConfigDataUtil.getMaterial(config, "material", null);
7579
blockData = ConfigDataUtil.getBlockData(config, "material", null);
7680
dustOptions = ConfigDataUtil.getDustOptions(config, "color", "size", new DustOptions(Color.RED, 1));
@@ -154,6 +158,12 @@ public Runnable playEffectLocation(Location location, SpellData data) {
154158
protected Object getParticleData(@NotNull Particle particle, @Nullable Entity entity, @NotNull Location location, @NotNull SpellData data) {
155159
Class<?> type = particle.getDataType();
156160

161+
if (type == Color.class) {
162+
return particle == Particle.ENTITY_EFFECT ?
163+
argbColor.get(data) :
164+
rgbColor.get(data);
165+
}
166+
157167
if (type == ItemStack.class) {
158168
Material material = this.material.get(data);
159169
return material == null ? null : new ItemStack(material);
@@ -216,7 +226,6 @@ protected Object getParticleData(@NotNull Particle particle, @Nullable Entity en
216226
if (type == DustOptions.class) return dustOptions.get(data);
217227
if (type == Particle.Spell.class) return spellOptions.get(data);
218228
if (type == DustTransition.class) return dustTransition.get(data);
219-
if (type == Color.class) return argbColor.get(data);
220229

221230
return switch (particle) {
222231
case SHRIEK -> shriekDelay.get(data);

core/src/main/java/com/nisovin/magicspells/spells/targeted/ParticleCloudSpell.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public class ParticleCloudSpell extends TargetedSpell implements TargetedLocatio
3232

3333
private final ConfigData<Component> customName;
3434

35-
private final ConfigData<Color> color;
35+
private final ConfigData<Color> rgbColor;
36+
private final ConfigData<Color> argbColor;
37+
3638
private final ConfigData<ItemStack> item;
3739
private final ConfigData<BlockData> blockData;
3840
private final ConfigData<DustOptions> dustOptions;
@@ -104,8 +106,8 @@ public ParticleCloudSpell(MagicConfig config, String spellName) {
104106
sculkChargeRotation = getConfigDataFloat("sculk-charge-rotation", 0);
105107

106108
ConfigData<Integer> colorInt = getConfigDataInt("color", 0xFF0000);
107-
color = ConfigDataUtil.getARGBColor(config.getMainConfig(), internalKey + "argb-color", null)
108-
.orDefault(data -> Color.fromRGB(colorInt.get(data)));
109+
rgbColor = getConfigDataColor("color", null).orDefault(data -> Color.fromRGB(colorInt.get(data)));
110+
argbColor = ConfigDataUtil.getARGBColor(config.getMainConfig(), internalKey + "argb-color", null).orDefault(rgbColor);
109111

110112
waitTime = getConfigDataInt("wait-time-ticks", 10);
111113
ticksDuration = getConfigDataInt("duration-ticks", 3 * TimeUtil.TICKS_PER_SECOND);
@@ -199,13 +201,18 @@ private CastResult spawnCloud(SpellData data) {
199201
private Object getParticleData(@NotNull Particle particle, @NotNull SpellData data) {
200202
Class<?> type = particle.getDataType();
201203

202-
if (type == Color.class) return color.get(data);
203204
if (type == ItemStack.class) return item.get(data);
204205
if (type == BlockData.class) return blockData.get(data);
205206
if (type == DustOptions.class) return dustOptions.get(data);
206207
if (type == Particle.Spell.class) return spellOptions.get(data);
207208
if (type == DustTransition.class) return dustTransition.get(data);
208209

210+
if (type == Color.class) {
211+
return particle == Particle.ENTITY_EFFECT ?
212+
argbColor.get(data) :
213+
rgbColor.get(data);
214+
}
215+
209216
return switch (particle) {
210217
case SHRIEK -> shriekDelay.get(data);
211218
case DRAGON_BREATH -> dragonBreathPower.get(data);

0 commit comments

Comments
 (0)