Allows creating a particle spawner without material configurations
This commit is contained in:
		@@ -6,6 +6,7 @@ import org.bukkit.Material;
 | 
				
			|||||||
import org.bukkit.World;
 | 
					import org.bukkit.World;
 | 
				
			||||||
import org.bukkit.block.Block;
 | 
					import org.bukkit.block.Block;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					import org.jetbrains.annotations.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.Collection;
 | 
					import java.util.Collection;
 | 
				
			||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
@@ -34,7 +35,7 @@ public final class ParticleSpawner implements Runnable {
 | 
				
			|||||||
     * @param blocks          <p>The blocks to spawn particles on</p>
 | 
					     * @param blocks          <p>The blocks to spawn particles on</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public ParticleSpawner(@NotNull ParticleConfig particleConfig,
 | 
					    public ParticleSpawner(@NotNull ParticleConfig particleConfig,
 | 
				
			||||||
                           @NotNull Map<Material, ParticleConfig> materialConfigs, @NotNull Collection<Block> blocks) {
 | 
					                           @Nullable Map<Material, ParticleConfig> materialConfigs, @NotNull Collection<Block> blocks) {
 | 
				
			||||||
        this.particleConfig = particleConfig;
 | 
					        this.particleConfig = particleConfig;
 | 
				
			||||||
        this.materialConfigs = materialConfigs;
 | 
					        this.materialConfigs = materialConfigs;
 | 
				
			||||||
        this.blocks = blocks;
 | 
					        this.blocks = blocks;
 | 
				
			||||||
@@ -51,7 +52,7 @@ public final class ParticleSpawner implements Runnable {
 | 
				
			|||||||
     * @param blockSupplier   <p>The supplier supplying the blocks to spawn particles on</p>
 | 
					     * @param blockSupplier   <p>The supplier supplying the blocks to spawn particles on</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public ParticleSpawner(@NotNull ParticleConfig particleConfig,
 | 
					    public ParticleSpawner(@NotNull ParticleConfig particleConfig,
 | 
				
			||||||
                           @NotNull Map<Material, ParticleConfig> materialConfigs,
 | 
					                           @Nullable Map<Material, ParticleConfig> materialConfigs,
 | 
				
			||||||
                           @NotNull Supplier<Collection<Block>> blockSupplier) {
 | 
					                           @NotNull Supplier<Collection<Block>> blockSupplier) {
 | 
				
			||||||
        this.particleConfig = particleConfig;
 | 
					        this.particleConfig = particleConfig;
 | 
				
			||||||
        this.materialConfigs = materialConfigs;
 | 
					        this.materialConfigs = materialConfigs;
 | 
				
			||||||
@@ -132,6 +133,9 @@ public final class ParticleSpawner implements Runnable {
 | 
				
			|||||||
     * @return <p>The particle config to use</p>
 | 
					     * @return <p>The particle config to use</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private @NotNull ParticleConfig getParticleConfig() {
 | 
					    private @NotNull ParticleConfig getParticleConfig() {
 | 
				
			||||||
 | 
					        if (this.materialConfigs == null) {
 | 
				
			||||||
 | 
					            return this.particleConfig;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        ParticleConfig materialConfig = this.materialConfigs.get(processingBlock.getType());
 | 
					        ParticleConfig materialConfig = this.materialConfigs.get(processingBlock.getType());
 | 
				
			||||||
        if (materialConfig != null) {
 | 
					        if (materialConfig != null) {
 | 
				
			||||||
            return materialConfig;
 | 
					            return materialConfig;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user