aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/commands/rome.kt
blob: 55f2c50f2cbfef56b96811547b794a1c5a023bcd (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
package moe.nea.notenoughupdates.commands

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


fun neuCommand() = literal("neu") {
    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()
        }
    }
    thenLiteral("repo") {
        thenExecute {
            setScreenLater(CottonClientScreen(repoGui()))
        }
    }
}


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