koca2000 / NoteBlockAPI

https://www.spigotmc.org/resources/noteblockapi.19287/
GNU Lesser General Public License v3.0
120 stars 40 forks source link

Events called by SongPlayer's loop can't be cancelled #55

Open koca2000 opened 4 years ago

koca2000 commented 4 years ago

When an event is called from SongPlayer's loop which is in async thread it can't be cancelled. Affected events are: SongLoopEvent and SongDestroyingEvent.

SongPlayer also continues playing the Song without waiting for event listeners of events bellow to finish their execution. Affected events are: SongStoppedEvent, SongNextEvent and SongEndEvent. For example when SongPlayer is paused in SongNextEvent it plays first few notes of the next Song before it's paused.

It is caused by schedulling the events execution in order to execute them in synchronized thread (not async with server main thread).

ishland commented 4 years ago

Simply calling event off-thread solves this