Skip to content

Commit fd40c8a

Browse files
committed
feat: Update 9.1
1 parent 152603a commit fd40c8a

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎build.gradle.kts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group = "eu.sporedev"
10-
version = "9.0"
10+
version = "9.1"
1111

1212
repositories {
1313
mavenCentral()

‎src/main/kotlin/me/clearedSpore/sporeAPI/SporePlugin.kt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import me.clearedSpore.sporeAPI.command.SporeCommand
1010
import me.clearedSpore.sporeAPI.command.SporeCommandManager
1111
import me.clearedSpore.sporeAPI.command.cloud.SporeCloudCommandManager
1212
import me.clearedSpore.sporeAPI.coroutine.SporeCoroutines
13+
import me.clearedSpore.sporeAPI.debug.LifecyclePhase
14+
import me.clearedSpore.sporeAPI.debug.SporeDebug
1315
import me.clearedSpore.sporeAPI.event.SporeListeners
1416
import me.clearedSpore.sporeAPI.scan.SporeScanner
1517
import 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()

‎src/main/kotlin/me/clearedSpore/sporeAPI/debug/SporeDebug.kt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ enum class MainThreadIoPolicy {
2121
class 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+
2432
object 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)

0 commit comments

Comments
 (0)