Fix dynmap version being null when dynmap doesn't support the minecraft versio

- Fixes #69
pull/95/head
trivernis 4 years ago
parent 65e3e090bb
commit 9b618eccc2

@ -9,6 +9,8 @@ import org.bstats.bukkit.Metrics
import org.bukkit.plugin.java.JavaPlugin import org.bukkit.plugin.java.JavaPlugin
import org.bukkit.scheduler.BukkitTask import org.bukkit.scheduler.BukkitTask
import org.dynmap.DynmapAPI import org.dynmap.DynmapAPI
import java.lang.IllegalStateException
import java.lang.NullPointerException
class Chunkmaster : JavaPlugin() { class Chunkmaster : JavaPlugin() {
lateinit var sqliteManager: SqliteManager lateinit var sqliteManager: SqliteManager
@ -103,11 +105,15 @@ class Chunkmaster : JavaPlugin() {
} }
private fun getDynmap(): DynmapAPI? { private fun getDynmap(): DynmapAPI? {
val dynmap = server.pluginManager.getPlugin("dynmap") return try {
return if (dynmap != null && dynmap is DynmapAPI) { val dynmap = server.pluginManager.getPlugin("dynmap")
logger.info(langManager.getLocalized("PLUGIN_DETECTED", "dynmap", dynmap.dynmapVersion)) if (dynmap != null && dynmap is DynmapAPI) {
dynmap logger.info(langManager.getLocalized("PLUGIN_DETECTED", "dynmap", dynmap.dynmapVersion))
} else { dynmap
} else {
null
}
} catch (e: IllegalStateException) {
null null
} }
} }

Loading…
Cancel
Save