Skip to content

Commit c68e65e

Browse files
committed
use daemons
1 parent bad2f73 commit c68e65e

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/1.18.x/src/main/kotlin/dev/traceld/plg/Plg.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ object Plg : IPlgMod {
5454
runWhenOn(Dist.DEDICATED_SERVER, toRun = {
5555
MOD_BUS.addListener(::setup)
5656
FORGE_BUS.addListener(::onServerSetup)
57-
FORGE_BUS.addListener(::onShutdown)
5857
FORGE_BUS.addListener(::onServerTick)
5958
})
6059
}
@@ -92,12 +91,6 @@ object Plg : IPlgMod {
9291
}
9392
}
9493

95-
private fun onShutdown(ev: ServerStoppedEvent) {
96-
_ticker.dispose()
97-
98-
LOGGER.info("Disposed ticker.")
99-
}
100-
10194
override fun getPlayerLocations(): List<PlayerLocation> {
10295
val currentTime = Instant.now().epochSecond
10396
val players = _minecraftServer.playerList.players

src/1.18.x/src/main/kotlin/dev/traceld/plg/base/PlgTicker.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
package dev.traceld.plg.base
22

33
import java.util.concurrent.Executors
4+
import java.util.concurrent.ThreadFactory
45

56
class PlgTicker(private val _impl: IPlgMod, private val _interval: Int, private val _locationLogger: LocationLogger) {
6-
private val _executor = Executors.newSingleThreadExecutor()
7+
private val _executor = Executors.newSingleThreadExecutor(ThreadFactory { r ->
8+
val t = Executors.defaultThreadFactory().newThread(r)
9+
10+
t.isDaemon = true
11+
12+
return@ThreadFactory t
13+
})
714

815
private var _lastLog: Long = 0
916

@@ -20,8 +27,4 @@ class PlgTicker(private val _impl: IPlgMod, private val _interval: Int, private
2027
}
2128
}
2229
}
23-
24-
fun dispose() {
25-
_executor.shutdown()
26-
}
2730
}

0 commit comments

Comments
 (0)