File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ class ConfigFactory(
4242 } else {
4343 createDefaultConfig(defaultConfig)
4444 }
45- startWatching()
45+
46+ registerWatcher()
4647 }
4748
4849 private fun createDefaultConfig (defaultConfig : Any ) {
@@ -71,15 +72,15 @@ class ConfigFactory(
7172 }
7273 }
7374
74- private fun startWatching () {
75+ private fun registerWatcher (): Job {
7576 val watchService = FileSystems .getDefault().newWatchService()
7677 path.parent?.register(
7778 watchService,
7879 StandardWatchEventKinds .ENTRY_CREATE ,
7980 StandardWatchEventKinds .ENTRY_MODIFY
8081 )
8182
82- watchJob = CoroutineScope (coroutineContext).launch {
83+ return CoroutineScope (coroutineContext).launch {
8384 watchService.use { watchService ->
8485 while (isActive) {
8586 val key = watchService.take()
@@ -91,12 +92,9 @@ class ConfigFactory(
9192 }
9293 }
9394 }
94- }
95+ }. also { watchJob = it }
9596 }
9697
97- /* *
98- * Handles a single watch event.
99- */
10098 private suspend fun handleWatchEvent (event : WatchEvent <* >) {
10199 val path = event.context() as ? Path ? : return
102100 if (! file.name.contains(path.toString())) return
You can’t perform that action at this time.
0 commit comments