Skip to content

Commit 0af7dd8

Browse files
committed
Update ParticleBuilder#color(Color, float) to also support Particle.Spell data type
1 parent a3f247c commit 0af7dd8

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

paper-api/src/main/java/com/destroystokyo/paper/ParticleBuilder.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public ParticleBuilder force(final boolean force) {
422422

423423
/**
424424
* Sets the particle Color.
425-
* Only valid for particles with a data type of {@link Color} or {@link Particle.DustOptions}.
425+
* Only valid for particles with a data type of {@link Color}, {@link Particle.DustOptions} or {@link Particle.Spell}.
426426
*
427427
* @param color the new particle color
428428
* @return a reference to this object.
@@ -435,28 +435,32 @@ public ParticleBuilder color(final @Nullable Color color) {
435435
}
436436

437437
/**
438-
* Sets the particle Color and size.
439-
* Only valid for particles with a data type of {@link Particle.DustOptions}.
438+
* Sets the particle Color and size or power.
439+
* Only valid for particles with a data type of {@link Particle.DustOptions} or {@link Particle.Spell}.
440440
*
441441
* @param color the new particle color
442-
* @param size the size of the particle
442+
* @param value the size or power of the particle
443443
* @return a reference to this object.
444444
*/
445-
public ParticleBuilder color(final @Nullable Color color, final float size) {
446-
if (this.particle.getDataType() != Particle.DustOptions.class && color != null) {
447-
throw new IllegalStateException("The combination of Color and size cannot be set on this particle type.");
445+
public ParticleBuilder color(final @Nullable Color color, final float value) {
446+
if (this.particle.getDataType() != Particle.DustOptions.class && this.particle.getDataType() != Particle.Spell.class && color != null) {
447+
throw new IllegalStateException("The combination of Color and float value cannot be set on this particle type.");
448448
}
449449

450450
// We don't officially support reusing these objects, but here we go
451451
if (color == null) {
452-
if (this.data instanceof Particle.DustOptions) {
452+
if (this.data instanceof Particle.DustOptions || this.data instanceof Particle.Spell) {
453453
return this.data(null);
454454
} else {
455455
return this;
456456
}
457457
}
458458

459-
return this.data(new Particle.DustOptions(color, size));
459+
if (this.particle.getDataType() == Particle.DustOptions.class) {
460+
return this.data(new Particle.DustOptions(color, value));
461+
} else {
462+
return this.data(new Particle.Spell(color, value));
463+
}
460464
}
461465

462466
/**

0 commit comments

Comments
 (0)