package net.knarcraft.knarlib.particle; import org.bukkit.Particle; import org.jetbrains.annotations.NotNull; /** * A builder for creating particle configurations * *

The default behavior will spawn a single particle with no offset or extra data, and density 1.

*/ @SuppressWarnings("unused") public class ParticleConfigBuilder { private final Particle particleType; private ParticleMode particleMode = ParticleMode.SINGLE; private int particleAmount = 1; private double particleDensity = 1; private double heightOffset = 0; private double offsetX = 0; private double offsetY = 0; private double offsetZ = 0; private double extra = 0; /** * Instantiates a new particle config builder * * @param particleType

The type of particle to spawn

*/ public ParticleConfigBuilder(@NotNull Particle particleType) { this.particleType = particleType; } /** * Sets the mode to use when spawning the particles * * @param particleMode

The mode to use

* @return

This particle configuration builder

*/ public @NotNull ParticleConfigBuilder setMode(@NotNull ParticleMode particleMode) { this.particleMode = particleMode; return this; } /** * Sets the amount of particles to spawn * * @param particleAmount

The number/amount of particles to spawn

* @return

This particle configuration builder

*/ public @NotNull ParticleConfigBuilder setAmount(int particleAmount) { this.particleAmount = particleAmount; return this; } /** * Sets the density of the particles to spawn * * @param particleDensity

The new density

* @return

This particle configuration builder

*/ public @NotNull ParticleConfigBuilder setDensity(double particleDensity) { this.particleDensity = particleDensity; return this; } /** * Sets the x,y,z offsets of the spawned particles * *

These values control the spread of the spawned particles

* * @param offsetX

The offset in the x-direction

* @param offsetY

The offset in the y-direction

* @param offsetZ

The offset in the z-direction

* @return

This particle configuration builder

*/ public @NotNull ParticleConfigBuilder setOffsets(double offsetX, double offsetY, double offsetZ) { this.offsetX = offsetX; this.offsetY = offsetY; this.offsetZ = offsetZ; return this; } /** * Sets the x offset of the spawned particles * * @param offsetX

The offset in the x-direction

* @return

This particle configuration builder

*/ public @NotNull ParticleConfigBuilder setXOffset(double offsetX) { this.offsetX = offsetX; return this; } /** * Sets the y offset of the spawned particles * * @param offsetY

The offset in the y-direction

* @return

This particle configuration builder

*/ public @NotNull ParticleConfigBuilder setYOffset(double offsetY) { this.offsetY = offsetY; return this; } /** * Sets the z offset of the spawned particles * * @param offsetZ

The offset in the z-direction

* @return

This particle configuration builder

*/ public @NotNull ParticleConfigBuilder setZOffset(double offsetZ) { this.offsetZ = offsetZ; return this; } /** * Sets the extra data for the spawned particles * * @param extra

The extra data to set

* @return

This particle configuration builder

*/ public @NotNull ParticleConfigBuilder setExtra(double extra) { this.extra = extra; return this; } /** * Sets the height offset for the spawned particles * * @param heightOffset

The height offset to use

* @return

This particle configuration builder

*/ public @NotNull ParticleConfigBuilder setHeightOffset(double heightOffset) { this.heightOffset = heightOffset; return this; } /** * Builds the particle configuration * * @return

The built particle configuration

*/ public @NotNull ParticleConfig build() { return new ParticleConfig(particleMode, particleType, particleAmount, particleDensity, heightOffset, offsetX, offsetY, offsetZ, extra); } }