File tree Expand file tree Collapse file tree
src/main/kotlin/me/clearedSpore/sporeAPI Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ plugins {
77}
88
99group = " eu.sporedev"
10- version = " 9.0 "
10+ version = " 9.1 "
1111
1212repositories {
1313 mavenCentral()
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import me.clearedSpore.sporeAPI.command.SporeCommand
1010import me.clearedSpore.sporeAPI.command.SporeCommandManager
1111import me.clearedSpore.sporeAPI.command.cloud.SporeCloudCommandManager
1212import me.clearedSpore.sporeAPI.coroutine.SporeCoroutines
13+ import me.clearedSpore.sporeAPI.debug.LifecyclePhase
14+ import me.clearedSpore.sporeAPI.debug.SporeDebug
1315import me.clearedSpore.sporeAPI.event.SporeListeners
1416import me.clearedSpore.sporeAPI.scan.SporeScanner
1517import me.clearedSpore.sporeAPI.scoreboard.SidebarManager
@@ -170,10 +172,13 @@ open class SporePlugin : JavaPlugin() {
170172
171173
172174 onPluginEnable()
175+
176+ SporeDebug .phase = LifecyclePhase .RUNNING
173177 Logger .info(" Plugin enabled." )
174178 }
175179
176180 final override fun onDisable () {
181+ SporeDebug .phase = LifecyclePhase .STOPPING
177182 SidebarManager .shutdown()
178183 Logger .info(" Shutting down scheduler..." )
179184 SporeScheduler .shutdown()
Original file line number Diff line number Diff line change @@ -21,6 +21,14 @@ enum class MainThreadIoPolicy {
2121class MainThreadIoException (operation : String ) :
2222 IllegalStateException (" Blocking call '$operation ' was made on the server thread" )
2323
24+ enum class LifecyclePhase {
25+ STARTING ,
26+
27+ RUNNING ,
28+
29+ STOPPING
30+ }
31+
2432object SporeDebug {
2533
2634 private const val MAX_WARNINGS = 20
@@ -34,6 +42,12 @@ object SporeDebug {
3442 @Volatile
3543 var mainThreadIoPolicy: MainThreadIoPolicy = MainThreadIoPolicy .WARN
3644
45+ @Volatile
46+ var phase: LifecyclePhase = LifecyclePhase .STARTING
47+
48+ @Volatile
49+ var reportDuringLifecycle: Boolean = false
50+
3751 private val warnings = ArrayDeque <MainThreadIo >()
3852 private val lastWarned = ConcurrentHashMap <String , Long >()
3953
@@ -60,6 +74,7 @@ object SporeDebug {
6074 internal fun check (operation : String ) {
6175 val policy = mainThreadIoPolicy
6276 if (policy == MainThreadIoPolicy .IGNORE ) return
77+ if (phase != LifecyclePhase .RUNNING && ! reportDuringLifecycle) return
6378 if (! Bukkit .isPrimaryThread()) return
6479
6580 record(operation, policy)
You can’t perform that action at this time.
0 commit comments