diff --git a/foundation-bifrost/build.gradle.kts b/foundation-bifrost/build.gradle.kts index af817e6..7bd630d 100644 --- a/foundation-bifrost/build.gradle.kts +++ b/foundation-bifrost/build.gradle.kts @@ -1,3 +1,5 @@ dependencies { implementation("net.dv8tion:JDA:5.0.0-alpha.2") + + compileOnly(project(":foundation-core")) } diff --git a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt index bba6d9c..db0fb42 100644 --- a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt +++ b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt @@ -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}") } } diff --git a/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/FoundationCorePlugin.kt b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/FoundationCorePlugin.kt index 5bbafcb..0856168 100644 --- a/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/FoundationCorePlugin.kt +++ b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/FoundationCorePlugin.kt @@ -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.