Skip to content

Commit

Permalink
Null check for sound threads
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Oct 2, 2024
1 parent 5e75ab8 commit 6db6ec0
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

Expand All @@ -24,8 +25,9 @@ public class SoundManagerMixin {
private static final Map<Thread, AtomicBoolean> threads = new ConcurrentHashMap<>();
@Redirect(method = "stopQueueAt", at = @At(value = "INVOKE", target = "Ljava/lang/Thread;stop()V"))
private void stopQueueAt(Thread thread) {
threads.get(thread).set(Boolean.FALSE);
Optional.ofNullable(threads.get(thread)).ifPresent(t -> t.set(false));
thread.interrupt();
threads.remove(thread);
}

@Inject(method = "queueSongsAt", at = @At(value = "INVOKE", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"))
Expand Down

0 comments on commit 6db6ec0

Please sign in to comment.