-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bundle modules into simplecoreapi
Due to the difficulty of loading modules dynamically into the classpath (at least in jaa 9 or superior) we'll be bundling the modules into the API.
- Loading branch information
Showing
37 changed files
with
1,956 additions
and
567 deletions.
There are no files selected for viewing
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
80 changes: 80 additions & 0 deletions
80
...in/kotlin/xyz/theprogramsrc/simplecoreapi/bungee/modules/tasksmodule/BungeeTasksModule.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,80 @@ | ||
package xyz.theprogramsrc.simplecoreapi.bungee.modules.tasksmodule | ||
|
||
import net.md_5.bungee.api.scheduler.ScheduledTask | ||
import net.md_5.bungee.api.scheduler.TaskScheduler | ||
import xyz.theprogramsrc.simplecoreapi.bungee.BungeeLoader | ||
import xyz.theprogramsrc.simplecoreapi.global.module.Module | ||
import xyz.theprogramsrc.simplecoreapi.global.module.ModuleDescription | ||
import xyz.theprogramsrc.simplecoreapi.global.modules.tasksmodule.models.RecurringTask | ||
import java.util.concurrent.TimeUnit | ||
|
||
class BungeeTasksModule: Module { | ||
|
||
|
||
companion object { | ||
/** | ||
* Instance of the [BungeeTasksModule]. | ||
*/ | ||
lateinit var instance: BungeeTasksModule | ||
private set | ||
} | ||
|
||
override val description: ModuleDescription = ModuleDescription( | ||
name = "TasksModule", | ||
version = "0.3.0", | ||
authors = listOf("Im-Fran"), | ||
) | ||
|
||
/** | ||
* BungeeCord Scheduler | ||
*/ | ||
val scheduler: TaskScheduler = BungeeLoader.instance.proxy.scheduler | ||
|
||
/** | ||
* Instance of Bungee Loader | ||
*/ | ||
private val plugin = BungeeLoader.instance | ||
|
||
override fun onEnable() { | ||
instance = this | ||
} | ||
|
||
override fun onDisable() { | ||
} | ||
|
||
/** | ||
* Runs an async task after the specified delay in ticks | ||
* @param delay The delay in ticks. Defaults to 1 (1 tick = 0.05 seconds) | ||
* @param task The task to run | ||
* @return the [ScheduledTask] | ||
*/ | ||
fun runAsync(delay: Int = 1, task: () -> Unit): ScheduledTask = scheduler.schedule(plugin, task, delay.times(50).toLong(), TimeUnit.MILLISECONDS) | ||
|
||
/** | ||
* Runs a repeating task asynchronously every given ticks (1 tick = 0.05 seconds) after the given ticks (1 tick = 0.05 seconds) | ||
* @param delay The delay in ticks. Defaults to 1 | ||
* @param period The period in ticks. Defaults to 1 | ||
* @param task The task to run | ||
* @return the [RecurringTask] | ||
*/ | ||
fun runAsyncRepeating(delay: Int = 1, period: Int = 1, task: () -> Unit): RecurringTask { | ||
val bungeeTask = scheduler.schedule(plugin, task, delay.times(50).toLong(), period.times(50).toLong(), TimeUnit.MILLISECONDS) | ||
return object: RecurringTask(){ | ||
var cancelled: Boolean = false | ||
|
||
override fun start(): RecurringTask = this.apply { | ||
if(cancelled) { | ||
this@BungeeTasksModule.runAsyncRepeating(delay, period, task) | ||
cancelled = false | ||
} | ||
} | ||
|
||
override fun stop(): RecurringTask = this.apply { | ||
bungeeTask.cancel() | ||
cancelled = true | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
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
128 changes: 0 additions & 128 deletions
128
...otlin/xyz/theprogramsrc/simplecoreapi/global/dependencydownloader/DependencyDownloader.kt
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...in/kotlin/xyz/theprogramsrc/simplecoreapi/global/dependencydownloader/DependencyLoader.kt
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...yz/theprogramsrc/simplecoreapi/global/dependencydownloader/interfaces/DependencyLoader.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.