Skip to content

Commit cf02a07

Browse files
authored
Add Particle.Spell support to ParticleBuilder#color(Color, float) (#13128)
1 parent 1d2d956 commit cf02a07

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

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

Lines changed: 16 additions & 12 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,33 +435,37 @@ 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
/**
463467
* Sets the particle Color.
464-
* Only valid for particles with a data type of {@link Color} or {@link Particle.DustOptions}.
468+
* Only valid for particles with a data type of {@link Color}, {@link Particle.DustOptions} or {@link Particle.Spell}.
465469
*
466470
* @param r red color component
467471
* @param g green color component
@@ -474,7 +478,7 @@ public ParticleBuilder color(final int r, final int g, final int b) {
474478

475479
/**
476480
* Sets the particle Color.
477-
* Only valid for particles with a data type of {@link Color} or {@link Particle.DustOptions}.
481+
* Only valid for particles with a data type of {@link Color}, {@link Particle.DustOptions} or {@link Particle.Spell}.
478482
* <p>
479483
* This method detects if the provided color integer is in RGB or ARGB format.
480484
* If the alpha channel is zero, it treats the color as RGB. Otherwise, it treats it as ARGB.
@@ -493,7 +497,7 @@ public ParticleBuilder color(final int color) {
493497

494498
/**
495499
* Sets the particle Color.
496-
* Only valid for particles with a data type of {@link Color} or {@link Particle.DustOptions}.
500+
* Only valid for particles with a data type of {@link Color}, {@link Particle.DustOptions} or {@link Particle.Spell}.
497501
*
498502
* @param a alpha color component
499503
* @param r red color component

0 commit comments

Comments
 (0)