
net.chestmc.StabilizedLoader.kt Maven / Gradle / Ivy
package net.chestmc
import net.chestmc.common.extensions.pluginManager
/**
* This object instance is used to obtain a stabilized class loader.
* This is util when getting a class from another jar file, avoiding the [ClassNotFoundException].
*/
object StabilizedLoader {
private val classLoader: ClassLoader by lazy {
try {
pluginManager.plugins[0].classLoader
} catch (ex: Exception) {
/* This is not the stabilized class loader */
/* this is used when the server not contains any plugin */
/* and this avoid a index out of bounds exception */
ClassLoader.getSystemClassLoader()
}
}
/**
* Gets the stabilized class loader.
*/
@JvmStatic
fun get(): ClassLoader = classLoader
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy