-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
109 additions
and
171 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
api/src/main/kotlin/dev/cubxity/plugins/metrics/api/scheduler/SchedulerTask.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
bukkit/src/main/kotlin/dev/cubxity/plugins/metrics/bukkit/BukkitDispatcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* UnifiedMetrics is a fully-featured metrics collection plugin for Minecraft servers. | ||
* Copyright (C) 2021 Cubxity | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package dev.cubxity.plugins.metrics.bukkit | ||
|
||
import kotlinx.coroutines.* | ||
import org.bukkit.Bukkit | ||
import org.bukkit.plugin.java.JavaPlugin | ||
import kotlin.coroutines.CoroutineContext | ||
|
||
@OptIn(InternalCoroutinesApi::class) | ||
class BukkitDispatcher(private val plugin: JavaPlugin) : CoroutineDispatcher(), Delay { | ||
@OptIn(ExperimentalCoroutinesApi::class) | ||
override fun scheduleResumeAfterDelay(timeMillis: Long, continuation: CancellableContinuation<Unit>) { | ||
val task = plugin.server.scheduler.runTaskLater( | ||
plugin, | ||
Runnable { | ||
continuation.apply { resumeUndispatched(Unit) } | ||
}, | ||
timeMillis / 50 | ||
) | ||
continuation.invokeOnCancellation { task.cancel() } | ||
} | ||
|
||
override fun dispatch(context: CoroutineContext, block: Runnable) { | ||
if (!context.isActive) { | ||
return | ||
} | ||
|
||
if (Bukkit.isPrimaryThread()) { | ||
block.run() | ||
} else { | ||
plugin.server.scheduler.runTask(plugin, block) | ||
} | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
bukkit/src/main/kotlin/dev/cubxity/plugins/metrics/bukkit/BukkitSchedulerAdapter.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
.../main/kotlin/dev/cubxity/plugins/metrics/common/plugin/scheduler/AbstractJavaScheduler.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.