Change isInitialized check

This commit is contained in:
Jakob K
2021-06-15 20:06:57 +02:00
parent 94a8fcedb8
commit 8ffaee3d51

View File

@@ -7,6 +7,12 @@ import net.axay.kspigot.languageextensions.kotlinextensions.closeIfInitialized
import net.axay.kspigot.runnables.KRunnableHolder
import org.bukkit.plugin.java.JavaPlugin
/**
* The main plugin instance.
*/
lateinit var KSpigotMainInstance: KSpigot
private set
/**
* This is the main instance of KSpigot.
*
@@ -43,7 +49,10 @@ abstract class KSpigot : JavaPlugin() {
open fun shutdown() {}
final override fun onLoad() {
internalMainInstance = this
if (::KSpigotMainInstance.isInitialized) {
console.warn("The main instance of KSpigot has been modified, even though it has already been set by another plugin!")
}
KSpigotMainInstance = this
load()
}
@@ -58,13 +67,3 @@ abstract class KSpigot : JavaPlugin() {
guiHolderProperty.closeIfInitialized()
}
}
private var internalMainInstance: KSpigot? = null
set(value) {
if (field != null) {
console.warn("The main instance of KSpigot has been modified, even though it has already been set by another plugin!")
}
field = value
}
val KSpigotMainInstance = internalMainInstance!!