Skip to content
Merged
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
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dependencies {
})
includeImplementation(libs.skyblockapi)
includeImplementation(libs.meowdding.lib)
includeImplementation(libs.meowdding.remote.repo)
includeImplementation(versionedCatalog["placeholders"])
modImplementation(libs.fabric.loader)
modImplementation(libs.repo.lib)
Expand Down
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ repo-lib = "3.0.2"
devauth = "1.2.1"

ksp = "2.2.10-2.0.2"
meowdding-resources = "1.0.15"

rconfigkt = "3.5.15"

gson = "2.12.1"

meowdding-resources = "1.0.15"
meowdding-ktmodules = "1.0.5"
meowdding-ktcodecs = "1.1.0"
meowdding-lib = "3.0.13"
meowdding-remote-repo = "1.0.2"

[libraries]

Expand All @@ -29,10 +31,12 @@ devauth = { module = "me.djtheredstoner:DevAuth-fabric", version.ref = "devauth"
resourceful-config-kotlin = { module = "com.teamresourceful.resourcefulconfigkt:resourcefulconfigkt-fabric-1.21.5", version.ref = "rconfigkt" }

gson = { module = "com.google.code.gson:gson", version.ref = "gson" }

meowdding-resources = { module = "me.owdding.repo:compacting-resources", version.ref = "meowdding-resources" }
meowdding-ktmodules = { module = "me.owdding.ktmodules:KtModules", version.ref = "meowdding-ktmodules" }
meowdding-ktcodecs = { module = "me.owdding.ktcodecs:KtCodecs", version.ref = "meowdding-ktcodecs" }
meowdding-lib = { module = "me.owdding.meowdding-lib:meowdding-lib", version.ref = "meowdding-lib" }
meowdding-remote-repo = { module = "me.owdding.repo:remote-repo", version.ref = "meowdding-remote-repo" }

[plugins]
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package me.owdding.mortem.config.category

import com.teamresourceful.resourcefulconfigkt.api.CategoryKt

object CommandsConfig : CategoryKt("commands") {
override val name = Translated("mortem.config.commands")

var join by boolean(true) {
translation = "mortem.config.commands.join"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.teamresourceful.resourcefulconfigkt.api.CategoryKt
import me.owdding.mortem.config.separator
import me.owdding.mortem.utils.colors.MortemColors
import net.minecraft.network.chat.Component
import net.minecraft.util.CommonColors
import tech.thatgravyboat.skyblockapi.api.profile.party.PartyAPI
import tech.thatgravyboat.skyblockapi.helpers.McClient
import tech.thatgravyboat.skyblockapi.utils.extentions.toFormattedName
Expand Down
69 changes: 69 additions & 0 deletions src/main/kotlin/me/owdding/mortem/features/comands/JoinCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package me.owdding.mortem.features.comands

import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
import me.owdding.ktmodules.Module
import me.owdding.lib.events.FinishRepoLoadingEvent
import me.owdding.mortem.config.category.CommandsConfig
import me.owdding.repo.RemoteRepo
import tech.thatgravyboat.skyblockapi.api.area.dungeon.DungeonFloor
import tech.thatgravyboat.skyblockapi.api.events.base.Subscription
import tech.thatgravyboat.skyblockapi.api.events.misc.RegisterCommandsEvent
import tech.thatgravyboat.skyblockapi.helpers.McClient
import tech.thatgravyboat.skyblockapi.utils.json.Json.toData

@Module
object JoinCommand {

private val dungeonsCommands = mutableMapOf<DungeonFloor, String>()
//private val kuudraCommands = mutableMapOf<KuudraTier, String>()

private val DUNGEON_FLOOR_CODEC: Codec<DungeonFloor> = Codec.STRING.xmap(
{ name -> DungeonFloor.getByName(name) },
{ floor -> floor?.name },
)
//private val KUUDRA_TIER_CODEC: Codec<KuudraTier> = Codec.STRING.xmap(
// { name -> KuudraTier.getByName(name) },
// { tier -> tier?.name },
//)

private val CODEC: Codec<Pair<Map<DungeonFloor, String>, Map<DungeonFloor, String>>> = RecordCodecBuilder.create {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably just return a unit

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ig but lazy

it.group(
Codec.unboundedMap(DUNGEON_FLOOR_CODEC, Codec.STRING).fieldOf("dungeons").forGetter { it.first },
Codec.unboundedMap(DUNGEON_FLOOR_CODEC, Codec.STRING).fieldOf("dungeons").forGetter { it.second },
//Codec.unboundedMap(KUUDRA_TIER_CODEC, Codec.STRING).fieldOf("kuudra").forGetter { it.second },
).apply(it) { a, b ->
dungeonsCommands.apply {
clear()
putAll(a)
}
//kuudraCommands.apply {
// clear()
// putAll(b)
//}
a to b
}
}

@Subscription
fun onCommand(event: RegisterCommandsEvent) {
if (!CommandsConfig.join) return

dungeonsCommands.forEach { (dungeon, command) ->
event.registerWithCallback("join${dungeon.name.lowercase()}") {
McClient.sendCommand("joininstance $command")
}
}
// kuudraCommands.forEach { (tier, command) ->
// event.registerWithCallback("joinkuudra${tier.name.lowercase()}") {
// McClient.sendCommand("joininstance $command")
// }
// }
}

@Subscription
fun onRepo(event: FinishRepoLoadingEvent) {
RemoteRepo.getFileContentAsJson("dungeons/joincommands.json")?.toData(CODEC)
}

}