aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/commands/rome.kt
blob: a60073a090de919e2edbb26387bb83f675fd64e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package moe.nea.notenoughupdates.commands

import com.mojang.brigadier.CommandDispatcher
import io.github.cottonmc.cotton.gui.client.CottonClientScreen
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.text.Text
import moe.nea.notenoughupdates.features.world.FairySouls
import moe.nea.notenoughupdates.gui.repoGui
import moe.nea.notenoughupdates.repo.RepoManager
import moe.nea.notenoughupdates.util.SBData
import moe.nea.notenoughupdates.util.ScreenUtil.setScreenLater


fun neuCommand() = literal("neu") {
    thenLiteral("repo") {
        thenLiteral("reload") {
            thenLiteral("fetch") {
                thenExecute {
                    source.sendFeedback(Text.translatable("notenoughupdates.repo.reload.network")) // TODO better reporting
                    RepoManager.launchAsyncUpdate()
                }
            }
            thenExecute {
                source.sendFeedback(Text.translatable("notenoughupdates.repo.reload.disk"))
                RepoManager.reload()
            }
        }
        thenExecute {
            setScreenLater(CottonClientScreen(repoGui()))
        }
    }
    thenLiteral("dev") {
        thenLiteral("config") {
            thenExecute {
                FairySouls.TConfig.showConfigEditor()
            }
        }
        thenLiteral("sbdata") {
            thenExecute {
                source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.profile", SBData.profileCuteName))
                val locrawInfo = SBData.locraw
                if (locrawInfo == null) {
                    source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.nolocraw"))
                } else {
                    source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.server", locrawInfo.server))
                    source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.gametype", locrawInfo.gametype))
                    source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.mode", locrawInfo.mode))
                    source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.map", locrawInfo.map))
                }

            }
        }
    }
}


fun registerNeuCommand(dispatcher: CommandDispatcher<FabricClientCommandSource>) {
    val neu = dispatcher.register(neuCommand())
    dispatcher.register(literal("alsoneu") {
        redirect(neu)
    })
}