From 8028a8556bdc66c6526c9768d5410029d4154081 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Wed, 27 Sep 2023 14:56:20 +0200 Subject: [PATCH] Allows creating a particle spawner without material configurations --- .../net/knarcraft/knarlib/particle/ParticleSpawner.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/knarcraft/knarlib/particle/ParticleSpawner.java b/src/main/java/net/knarcraft/knarlib/particle/ParticleSpawner.java index 8faa133..619e483 100644 --- a/src/main/java/net/knarcraft/knarlib/particle/ParticleSpawner.java +++ b/src/main/java/net/knarcraft/knarlib/particle/ParticleSpawner.java @@ -6,6 +6,7 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.Map; @@ -34,7 +35,7 @@ public final class ParticleSpawner implements Runnable { * @param blocks

The blocks to spawn particles on

*/ public ParticleSpawner(@NotNull ParticleConfig particleConfig, - @NotNull Map materialConfigs, @NotNull Collection blocks) { + @Nullable Map materialConfigs, @NotNull Collection blocks) { this.particleConfig = particleConfig; this.materialConfigs = materialConfigs; this.blocks = blocks; @@ -51,7 +52,7 @@ public final class ParticleSpawner implements Runnable { * @param blockSupplier

The supplier supplying the blocks to spawn particles on

*/ public ParticleSpawner(@NotNull ParticleConfig particleConfig, - @NotNull Map materialConfigs, + @Nullable Map materialConfigs, @NotNull Supplier> blockSupplier) { this.particleConfig = particleConfig; this.materialConfigs = materialConfigs; @@ -132,6 +133,9 @@ public final class ParticleSpawner implements Runnable { * @return

The particle config to use

*/ private @NotNull ParticleConfig getParticleConfig() { + if (this.materialConfigs == null) { + return this.particleConfig; + } ParticleConfig materialConfig = this.materialConfigs.get(processingBlock.getType()); if (materialConfig != null) { return materialConfig;