@@ -82,7 +82,7 @@ public class BCauldron {
8282 private Color particleColor ;
8383 private final Location particleLocation ;
8484 private final UUID id ;
85- private volatile MyScheduledTask foliaParticleTask ;
85+ private MyScheduledTask foliaParticleTask ;
8686
8787 public BCauldron (Block block ) {
8888 this .block = block ;
@@ -422,41 +422,42 @@ public static void processCookEffects() {
422422 }
423423 }
424424
425- public void startFoliaParticleTask () {
426- if (!VERSION .isFolia () || !config .isEnableCauldronParticles ()) {
425+ private synchronized void startFoliaParticleTask () {
426+ if (!VERSION .isFolia ()) {
427+ return ;
428+ }
429+ if (!config .isEnableCauldronParticles ()) {
430+ stopFoliaParticleTask ();
427431 return ;
428432 }
429- synchronized (this ) {
430- if (foliaParticleTask != null && !foliaParticleTask .isCancelled ()) {
433+ if (foliaParticleTask != null && !foliaParticleTask .isCancelled ()) {
434+ return ;
435+ }
436+ long delay = ThreadLocalRandom .current ().nextLong (1 , PARTICLEPAUSE + 1L );
437+ foliaParticleTask = BreweryPlugin .getScheduler ().runTaskTimer (block .getLocation (), () -> {
438+ if (config .isMinimalParticles () && ThreadLocalRandom .current ().nextFloat () > 0.5f ) {
431439 return ;
432440 }
433- long delay = ThreadLocalRandom .current ().nextLong (1 , PARTICLEPAUSE + 1L );
434- foliaParticleTask = BreweryPlugin .getScheduler ().runTaskTimer (block .getLocation (), () -> {
435- if (!config .isEnableCauldronParticles ()) {
436- return ;
437- }
438- if (config .isMinimalParticles () && ThreadLocalRandom .current ().nextFloat () > 0.5f ) {
439- return ;
440- }
441- cookEffect ();
442- }, delay , PARTICLEPAUSE );
443- }
441+ cookEffect ();
442+ }, delay , PARTICLEPAUSE );
444443 }
445444
446- public void stopFoliaParticleTask () {
445+ private synchronized void stopFoliaParticleTask () {
447446 if (!VERSION .isFolia ()) {
448447 return ;
449448 }
450- synchronized (this ) {
451- if (foliaParticleTask != null ) {
452- foliaParticleTask .cancel ();
453- foliaParticleTask = null ;
454- }
449+ if (foliaParticleTask != null ) {
450+ foliaParticleTask .cancel ();
451+ foliaParticleTask = null ;
455452 }
456453 }
457454
458455 public static void startAllFoliaParticleTasks () {
459- if (!VERSION .isFolia () || !config .isEnableCauldronParticles ()) {
456+ if (!VERSION .isFolia ()) {
457+ return ;
458+ }
459+ if (!config .isEnableCauldronParticles ()) {
460+ stopAllFoliaParticleTasks ();
460461 return ;
461462 }
462463 for (BCauldron cauldron : bcauldrons .values ()) {
0 commit comments