Compare commits
3 Commits
b56a8b0cad
...
fd267a4b10
Author | SHA1 | Date | |
---|---|---|---|
fd267a4b10 | |||
a86e8b1ebe | |||
e22ff551df |
@ -26,7 +26,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "fr.username404"
|
group = "fr.username404"
|
||||||
version = "0.3.5"
|
version = "0.3.6"
|
||||||
val groupAndName = "${rootProject.group}.${rootProject.name.lowercase()}"
|
val groupAndName = "${rootProject.group}.${rootProject.name.lowercase()}"
|
||||||
|
|
||||||
val javaVer: String = "21"
|
val javaVer: String = "21"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
architectury { common("fabric", "neoforge"); injectInjectables = false }
|
architectury { common("fabric", "neoforge"); injectInjectables = true }
|
||||||
dependencies {
|
dependencies {
|
||||||
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}")
|
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}")
|
||||||
modImplementation("me.shedaniel.cloth:cloth-config:${rootProject.property("clothconfig_version")}") {
|
modImplementation("me.shedaniel.cloth:cloth-config:${rootProject.property("clothconfig_version")}") {
|
||||||
|
@ -8,34 +8,30 @@ import com.typesafe.config.ConfigFactory.parseFile
|
|||||||
import com.typesafe.config.ConfigFactory.parseString
|
import com.typesafe.config.ConfigFactory.parseString
|
||||||
import com.typesafe.config.ConfigRenderOptions
|
import com.typesafe.config.ConfigRenderOptions
|
||||||
import com.typesafe.config.ConfigValueFactory
|
import com.typesafe.config.ConfigValueFactory
|
||||||
|
import dev.architectury.injectables.targets.ArchitecturyTarget
|
||||||
import fr.username404.snowygui.ClickGui
|
import fr.username404.snowygui.ClickGui
|
||||||
import fr.username404.snowygui.Snowy
|
import fr.username404.snowygui.Snowy
|
||||||
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
||||||
import fr.username404.snowygui.gui.feature.shouldSave
|
|
||||||
import fr.username404.snowygui.gui.feature.Category
|
import fr.username404.snowygui.gui.feature.Category
|
||||||
import fr.username404.snowygui.gui.feature.Macro
|
import fr.username404.snowygui.gui.feature.Macro
|
||||||
|
import fr.username404.snowygui.gui.feature.shouldSave
|
||||||
import io.github.config4k.extract
|
import io.github.config4k.extract
|
||||||
import io.github.config4k.getValue
|
import io.github.config4k.getValue
|
||||||
import net.minecraft.client.Minecraft
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
import kotlin.reflect.KProperty
|
|
||||||
import kotlinx.coroutines.CoroutineStart
|
import kotlinx.coroutines.CoroutineStart
|
||||||
import kotlinx.coroutines.coroutineScope
|
import kotlinx.coroutines.coroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
|
||||||
import kotlinx.serialization.decodeFromString
|
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import net.minecraft.network.chat.MutableComponent
|
|
||||||
import net.minecraft.network.chat.contents.TranslatableContents
|
import net.minecraft.network.chat.contents.TranslatableContents
|
||||||
import org.jetbrains.annotations.ApiStatus
|
import org.jetbrains.annotations.ApiStatus
|
||||||
|
import java.io.File
|
||||||
|
import java.nio.file.Path
|
||||||
|
import kotlin.io.path.absolutePathString
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
import kotlin.reflect.full.isSuperclassOf
|
import kotlin.reflect.full.isSuperclassOf
|
||||||
|
|
||||||
@OptIn(ExperimentalSerializationApi::class)
|
|
||||||
object Configuration {
|
object Configuration {
|
||||||
@Deprecated("Use the getValue or setValue methods instead", level = DeprecationLevel.ERROR)
|
@Deprecated("Use the getValue or setValue methods instead", level = DeprecationLevel.ERROR)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ -54,7 +50,19 @@ object Configuration {
|
|||||||
}.toTypedArray()),
|
}.toTypedArray()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
private val configDirectory: String = (Minecraft.getInstance().gameDirectory.absolutePath + File.separator + "config").also { File(it).mkdir() }
|
private val configDirectory: String =
|
||||||
|
(if (ArchitecturyTarget.getCurrentTarget() == "fabric") {
|
||||||
|
Class.forName("net.fabricmc.loader.api.FabricLoader").run {
|
||||||
|
getMethod("getConfigDir").invoke(getMethod("getInstance").invoke(null))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Class.forName("net.neoforged.fml.loading.FMLPaths")
|
||||||
|
.getField("CONFIGDIR")
|
||||||
|
.get(null)
|
||||||
|
.let { enum ->
|
||||||
|
enum.javaClass.getMethod("get").invoke(enum)
|
||||||
|
}
|
||||||
|
} as Path).absolutePathString()
|
||||||
private val file: File = File(configDirectory + File.separator + "snowy.conf")
|
private val file: File = File(configDirectory + File.separator + "snowy.conf")
|
||||||
private val obtained: Config = run {
|
private val obtained: Config = run {
|
||||||
var result: Config = empty()
|
var result: Config = empty()
|
||||||
@ -87,11 +95,7 @@ object Configuration {
|
|||||||
val enabledFeatures = mutableMapOf<String, Boolean>().apply {
|
val enabledFeatures = mutableMapOf<String, Boolean>().apply {
|
||||||
"enabledFeatures".let { obtained.run {
|
"enabledFeatures".let { obtained.run {
|
||||||
if (hasPath(it)) {
|
if (hasPath(it)) {
|
||||||
putAll(extract<Map<out String, Boolean>>(it).filterKeys { keyName -> ClickGui.clickBoxes.any {
|
putAll(extract<Map<out String, Boolean>>(it))
|
||||||
it.buttons.any { button ->
|
|
||||||
button.info.shouldSave() && button.title == keyName
|
|
||||||
}
|
|
||||||
}})
|
|
||||||
}
|
}
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
|
@ -17,25 +17,20 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||||||
private fun addButtons(vararg buttons: ButtonImpl) {
|
private fun addButtons(vararg buttons: ButtonImpl) {
|
||||||
buttons.groupBy { impl ->
|
buttons.groupBy { impl ->
|
||||||
ClickGui.clickBoxes.find { box ->
|
ClickGui.clickBoxes.find { box ->
|
||||||
with(impl) {
|
box.isCategory(impl.info.parent)
|
||||||
|
}
|
||||||
|
}.entries.forEach { entry -> entry.run {
|
||||||
|
key?.buttons?.clear()
|
||||||
|
value.forEach { if (!it.isDisabled) {
|
||||||
|
key?.buttons?.add(it.apply {
|
||||||
if (info.shouldSave() && !info.parent.shouldHide) {
|
if (info.shouldSave() && !info.parent.shouldHide) {
|
||||||
Configuration.enabledFeatures[title]?.let { bool ->
|
Configuration.enabledFeatures[title]?.let { bool ->
|
||||||
toggled = bool
|
toggled = bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
box.isCategory(info.parent)
|
})
|
||||||
}
|
} }
|
||||||
}
|
} }
|
||||||
}.entries.forEach { entry ->
|
|
||||||
with(entry) {
|
|
||||||
key?.buttons?.clear()
|
|
||||||
value.forEach {
|
|
||||||
if (!it.isDisabled) {
|
|
||||||
key?.buttons?.add(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun initButtons() = addButtons(
|
fun initButtons() = addButtons(
|
||||||
|
@ -9,12 +9,13 @@ import net.arikia.dev.drpc.DiscordRPC as discord_rpc
|
|||||||
@ButtonInfo(Category.MISC)
|
@ButtonInfo(Category.MISC)
|
||||||
object DiscordRPC: ButtonImpl() {
|
object DiscordRPC: ButtonImpl() {
|
||||||
private val RPCHandlers: DiscordEventHandlers = DiscordEventHandlers.Builder().build()
|
private val RPCHandlers: DiscordEventHandlers = DiscordEventHandlers.Builder().build()
|
||||||
private val RichPresence: DiscordRichPresence.Builder = DiscordRichPresence
|
private val RichPresence: Lazy<DiscordRichPresence.Builder> = lazy { DiscordRichPresence
|
||||||
.Builder("Playing Minecraft ${Minecraft.getInstance().launchedVersion}")
|
.Builder("Playing Minecraft ${Minecraft.getInstance().launchedVersion}")
|
||||||
.setDetails("Launched with ${Minecraft.getInstance().versionType}")
|
.setDetails("Launched with ${Minecraft.getInstance().versionType}")
|
||||||
.setBigImage("icon", "SnowyGUI")
|
.setBigImage("icon", "SnowyGUI")
|
||||||
|
}
|
||||||
override fun execAction() {
|
override fun execAction() {
|
||||||
if (toggled) discord_rpc.discordUpdatePresence(RichPresence.build())
|
if (toggled) discord_rpc.discordUpdatePresence(RichPresence.value.build())
|
||||||
else discord_rpc.discordClearPresence()
|
else discord_rpc.discordClearPresence()
|
||||||
}
|
}
|
||||||
init {
|
init {
|
||||||
|
Loading…
Reference in New Issue
Block a user