How would you spawn particles that stay longer than just a few seconds/respawn them once their gone?
You can’t, unfortunately. While particles are actual entities in 1.8.x, they’re spawned on the client through their own packet. The server doesn’t have any control over them despawning.
Ok. I found a solution using SpongeExecutors.
It works quite well with SpongeExecutors:
ParticleService = ParticleService = scheduler.createSyncExecutor(this);
ParticleService.scheduleWithFixedDelay
(()->
{
getPlayer().spawnParticles(ParticleEffect.builder().type(ParticleTypes.REDSTONE).build(), pos, radius);
} ,0,200, TimeUnit.MILLISECONDS
);
Not sure if that’s the best solution though.
Is it possible to stop a SpongeExecutorService
/interrupt the process?
When scheduling the task, the method returns you a SpongeFuture, which you can use to obtain a Task. The Task
can be used to remove the task from the scheduler. Should you require the task to be able to cancel itself, schedule a Consumer<Task>
instead of a Runnable
to have access to the Task
object within the task itself.
Alternatively cancelling the SpongeFuture
with <future>.cancel(true)
will do the same thing.
Edit: In addition the spec for repeating tasks is that it will cease repeating if an exception is thrown during execution, so that is another method of stopping the task.