Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/ClientCheck.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package at.hannibal2.skyhanni.utils

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.compat.append
import at.hannibal2.skyhanni.utils.compat.bold
import at.hannibal2.skyhanni.utils.compat.componentBuilder
import at.hannibal2.skyhanni.utils.compat.underlined
import at.hannibal2.skyhanni.utils.compat.url
import at.hannibal2.skyhanni.utils.system.PlatformUtils

@SkyHanniModule
object ClientCheck {
private val clientName: String? by lazy {
when {
PlatformUtils.isModInstalled("ichor") ->
"Lunar Client"
PlatformUtils.isAnyModInstalled("feather", "feather-loader") ->
"Feather Client"
else ->
null
}
}

@HandleEvent
fun onProfileJoin() {
val clientName = clientName ?: return

ChatUtils.chat(
componentBuilder {
append("You appear to be using ")
append(clientName) { bold = true }
append(
". This is a closed source client that may cause issues we are unable to fix. " +
"We strongly recommend switching to a supported configuration, such as "
)
// TODO: remove conditional once Modrinth Launcher is fixed on Linux
if (!OSUtils.isLinux) {
append("Modrinth Launcher") {
url = "https://modrinth.com/app"
underlined = true
}
append(" or ")
}
append("Prism Launcher") {
url = "https://prismlauncher.org/"
underlined = true
}
append(".")
}
)
}

@HandleEvent
fun onDebug(event: DebugDataCollectEvent) {
event.title("Client Check")
event.addData("Client name: $clientName")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ object PlatformUtils {

fun Class<*>.getModInstance(): ModInstance? = getModFromPackage(canonicalName?.substringBeforeLast('.'))

fun isModInstalled(modId: String): Boolean {
return FabricLoader.getInstance().isModLoaded(modId)
}
fun isModInstalled(modId: String): Boolean =
FabricLoader.getInstance().isModLoaded(modId)

fun isAnyModInstalled(vararg modIds: String): Boolean =
modIds.any(::isModInstalled)

fun isMcAbove(version: String): Boolean {
return MCVersion.fromString(version) > MCVersion.currentMcVersion
Expand Down
Loading