Skip to content

Commit

Permalink
fix init in server.
Browse files Browse the repository at this point in the history
  • Loading branch information
way-zer committed Aug 4, 2024
1 parent 39bfedd commit ef8172b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/cf/wayzer/contentsTweaker/CTNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class CTNode private constructor() : ExtendableClass<CTExtInfo>() {
}

val resetHandlers = mutableSetOf<Resettable>()
private val afterHandlers = mutableSetOf<AfterHandler>()
internal val afterHandlers = mutableSetOf<AfterHandler>()

fun modified(modifiable: Modifiable<*>) {
resetHandlers.add(modifiable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ object ContentsTweaker {
)

fun afterHandle() {
if (CTNode.PatchHandler.afterHandlers.isEmpty()) return
val time = measureTimeMillis {
CTNode.PatchHandler.doAfterHandle()
}
Expand Down
20 changes: 11 additions & 9 deletions src/main/kotlin/cf/wayzer/contentsTweaker/ModMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ class ModMain : Mod() {
}
ContentsTweaker.afterHandle()
}
Vars.netClient.addPacketHandler("ContentsLoader|newPatch") {
val (name, content) = it.split('\n', limit = 2)
ContentsTweaker.loadPatch(name, content)
}
//TODO: Deprecated
Vars.netClient.addPacketHandler("ContentsLoader|loadPatch") { name ->
val patch = Vars.state.map.tags.get("CT@$name")
?: return@addPacketHandler Call.serverPacketReliable("ContentsLoader|requestPatch", name)
ContentsTweaker.loadPatch(name, patch)
if (Vars.netClient != null) {
Vars.netClient.addPacketHandler("ContentsLoader|newPatch") {
val (name, content) = it.split('\n', limit = 2)
ContentsTweaker.loadPatch(name, content)
}
//TODO: Deprecated
Vars.netClient.addPacketHandler("ContentsLoader|loadPatch") { name ->
val patch = Vars.state.map.tags.get("CT@$name")
?: return@addPacketHandler Call.serverPacketReliable("ContentsLoader|requestPatch", name)
ContentsTweaker.loadPatch(name, patch)
}
}
Vars.mods.scripts.scope.apply {
put("CT", this, ContentsTweaker)
Expand Down

0 comments on commit ef8172b

Please sign in to comment.