Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use launch over async to prevent error supression #13

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.noxcrew.interfaces.utilities.CollapsablePaneMap
import com.noxcrew.interfaces.utilities.InterfacesCoroutineDetails
import com.noxcrew.interfaces.utilities.forEachInGrid
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.withTimeout
Expand Down Expand Up @@ -257,7 +256,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa

// Start the job if it's not running currently!
if (transformingJob == null || transformingJob?.isCompleted == true) {
transformingJob = SCOPE.async(
transformingJob = SCOPE.launch(
InterfacesCoroutineDetails(player.uniqueId, "running and applying a transform")
) {
// Go through all pending transforms one at a time until
Expand All @@ -267,15 +266,11 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
// Removes the first pending transform
val transform = pendingTransforms.remove()

try {
// Don't run transforms for an offline player!
if (!Bukkit.isStopping() && player.isOnline) {
withTimeout(6.seconds) {
runTransformAndApplyToPanes(transform)
}
// Don't run transforms for an offline player!
if (!Bukkit.isStopping() && player.isOnline) {
withTimeout(6.seconds) {
runTransformAndApplyToPanes(transform)
}
} catch (exception: Exception) {
logger.error("Failed to run and apply transform: $transform", exception)
}
}

Expand Down
Loading