mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-02 21:20:55 +00:00
Test plugin dependencies and casting the existing instance.
This commit is contained in:
parent
aed37ae013
commit
e303f6f937
@ -1,3 +1,5 @@
|
||||
dependencies {
|
||||
implementation("net.dv8tion:JDA:5.0.0-alpha.2")
|
||||
|
||||
compileOnly(project(":foundation-core"))
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package cloud.kubelet.foundation.bifrost
|
||||
|
||||
import cloud.kubelet.foundation.core.FoundationCorePlugin
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
|
||||
class FoundationBifrostPlugin : JavaPlugin() {
|
||||
override fun onEnable() {
|
||||
slF4JLogger.info("Enabling!")
|
||||
|
||||
val foundation = server.pluginManager.getPlugin("Foundation") as FoundationCorePlugin
|
||||
slF4JLogger.info("Plugin data path: ${foundation.pluginDataPath}")
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,30 @@ import org.bukkit.command.CommandExecutor
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
import java.nio.file.Path
|
||||
|
||||
class FoundationCorePlugin : JavaPlugin(), Listener {
|
||||
private lateinit var _pluginDataPath: Path
|
||||
|
||||
var pluginDataPath: Path
|
||||
/**
|
||||
* Data path of the core plugin.
|
||||
* Can be used as a sanity check of sorts for dependencies to be sure the plugin is loaded.
|
||||
*/
|
||||
get() {
|
||||
if (!::_pluginDataPath.isInitialized) {
|
||||
throw Exception("FoundationCore is not loaded!")
|
||||
}
|
||||
return _pluginDataPath
|
||||
}
|
||||
private set(value) { _pluginDataPath = value }
|
||||
|
||||
override fun onEnable() {
|
||||
val dataPath = dataFolder.toPath()
|
||||
val backupPath = dataPath.resolve(BACKUPS_DIRECTORY)
|
||||
pluginDataPath = dataFolder.toPath()
|
||||
val backupPath = pluginDataPath.resolve(BACKUPS_DIRECTORY)
|
||||
|
||||
// Create Foundation plugin directories.
|
||||
dataPath.toFile().mkdir()
|
||||
pluginDataPath.toFile().mkdir()
|
||||
backupPath.toFile().mkdir()
|
||||
|
||||
// Register this as an event listener.
|
||||
|
Loading…
Reference in New Issue
Block a user