Skip to content

Commit

Permalink
Prevent startup with FAWE installed
Browse files Browse the repository at this point in the history
Resolves #560
  • Loading branch information
NichtStudioCode committed Jan 22, 2025
1 parent d5ee0e1 commit 057c3bc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 99 deletions.
12 changes: 0 additions & 12 deletions nova-hooks/nova-hook-fastasyncworldedit/build.gradle.kts

This file was deleted.

This file was deleted.

38 changes: 29 additions & 9 deletions nova/src/main/kotlin/xyz/xenondevs/nova/Nova.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.serialization.gson.*
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.core.LoggerContext
import org.bukkit.Bukkit
import org.bukkit.plugin.java.JavaPlugin
import xyz.xenondevs.invui.InvUI
Expand Down Expand Up @@ -42,18 +44,36 @@ internal val HTTP_CLIENT = HttpClient(CIO) {
internal var PLUGIN_READY = false
private set

private val INCOMPATIBLE_PLUGINS = setOf(
// FAWE replaces LevelChunkSections, preventing Nova from doing block migrations & world gen
// https://github.com/xenondevs/Nova/issues/560
"FastAsyncWorldEdit"
)

internal object Nova : JavaPlugin(), INova {

override fun onEnable() {
if (BOOTSTRAPPER.remainingAddons > 0)
throw IllegalStateException("${BOOTSTRAPPER.remainingAddons} addons did not load.")

PLUGIN_READY = true
LIFECYCLE_MANAGER = lifecycleManager

InvUI.getInstance().setPlugin(this)
Languages.getInstance().enableServerSideTranslations(false)
Initializer.registerEvents()
try {
if (BOOTSTRAPPER.remainingAddons > 0)
throw IllegalStateException("${BOOTSTRAPPER.remainingAddons} addons did not load.")

val incompatibilities = Bukkit.getServer().pluginManager.plugins
.map { it.name }
.filter { it in INCOMPATIBLE_PLUGINS }
if (incompatibilities.isNotEmpty())
throw Exception("Nova is not compatible with the following plugin(s): ${incompatibilities.joinToString()}")

PLUGIN_READY = true
LIFECYCLE_MANAGER = lifecycleManager

InvUI.getInstance().setPlugin(this)
Languages.getInstance().enableServerSideTranslations(false)
Initializer.registerEvents()
} catch (t: Throwable) {
LOGGER.error("", t)
(LogManager.getContext(false) as LoggerContext).stop() // flush log messages
Runtime.getRuntime().halt(-1) // force-quit
}
}

override fun onDisable() {
Expand Down
6 changes: 2 additions & 4 deletions nova/src/main/kotlin/xyz/xenondevs/nova/NovaBootstrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import xyz.xenondevs.nova.util.data.Version
import xyz.xenondevs.nova.util.data.VersionRange
import xyz.xenondevs.nova.util.data.useZip
import java.nio.file.Path
import kotlin.collections.component1
import kotlin.collections.component2
import kotlin.io.path.Path
import kotlin.io.path.exists

Expand Down Expand Up @@ -105,8 +103,8 @@ internal class NovaBootstrapper : PluginBootstrap {
Configs.extractDefaultConfig()
CBFAdapters.register()
Initializer.start()
} catch (e: Exception) {
LOGGER.error("", e)
} catch (t: Throwable) {
LOGGER.error("", t)
(LogManager.getContext(false) as LoggerContext).stop() // flush log messages
Runtime.getRuntime().halt(-1) // force-quit
}
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ include("nova-api")
include("nova-gradle-plugin")

// hooks
include("nova-hooks:nova-hook-fastasyncworldedit")
include("nova-hooks:nova-hook-griefprevention")
include("nova-hooks:nova-hook-itemsadder")
include("nova-hooks:nova-hook-luckperms")
Expand Down

0 comments on commit 057c3bc

Please sign in to comment.