Skip to content

Commit

Permalink
fix: notify nested parents of child closure
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Nov 11, 2024
1 parent 006aae1 commit 0914cf7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ kotlin_version=2.0.21
fabric_kotlin_version=1.12.3

# mod properties
mod_version=1.4
mod_version=1.4.1
maven_group=net.mcbrawls
mod_id=slate
17 changes: 15 additions & 2 deletions src/main/kotlin/net/mcbrawls/slate/Slate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,21 @@ open class Slate {
// invoke callbacks
callbackHandler.collectCallbacks<SlateCloseCallback>().invoke(this, player)

parent?.also { parent ->
parent.callbackHandler.collectCallbacks<ChildSlateCloseCallback>().invoke(this, player)
parent?.also { firstParent ->
val parents: List<Slate> = buildList {
add(firstParent)

// add nested parents
var nestedParent = firstParent.parent
while (nestedParent != null) {
add(nestedParent)
nestedParent = nestedParent.parent
}
}

parents.forEach { parent ->
parent.callbackHandler.collectCallbacks<ChildSlateCloseCallback>().invoke(this, player)
}
}
}
}
Expand Down

0 comments on commit 0914cf7

Please sign in to comment.