|
1 | 1 | package org.polyfrost.crashpatch.client |
2 | 2 |
|
3 | 3 | import com.mojang.brigadier.Command |
| 4 | +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback |
| 5 | +import net.fabricmc.fabric.api.client.command.v2.ClientCommands |
| 6 | +import net.minecraft.network.chat.Component |
| 7 | +import net.minecraft.util.CommonColors |
4 | 8 | import org.apache.logging.log4j.LogManager |
5 | 9 | import org.polyfrost.crashpatch.CrashPatchConstants |
| 10 | +import org.polyfrost.crashpatch.client.CrashPatchClient.isSkyClient |
6 | 11 | import org.polyfrost.crashpatch.client.crashes.CrashScanner |
7 | 12 | import org.polyfrost.oneconfig.utils.v1.Multithreading |
8 | | -import org.polyfrost.oneconfig.utils.v1.dsl.createScreen |
| 13 | +import org.polyfrost.oneconfig.utils.v1.dsl.mc |
9 | 14 | import kotlin.io.path.exists |
10 | 15 |
|
11 | 16 | object CrashPatchClient { |
@@ -33,27 +38,21 @@ object CrashPatchClient { |
33 | 38 | fun initialize() { |
34 | 39 | CrashPatchConfig.preload() // Initialize the config |
35 | 40 |
|
36 | | - OmniClientCommands.command(CrashPatchConstants.ID) { |
37 | | - runs { ctx -> |
38 | | - ctx.source.openScreen(CrashPatchConfig.createScreen()) |
39 | | - } |
40 | | - |
41 | | - then("reload") { |
42 | | - runs { ctx -> |
43 | | - val success = CrashScanner.submitCacheRequest() |
44 | | - |
45 | | - val content = "Requested reload of crash data! Please wait." to TextColors.GREEN |
46 | | - val (message, color) = content |
47 | | - ctx.source.replyChat(Text.literal("[${CrashPatchConstants.NAME}] $message").setStyle(MCTextStyle.color(color))) |
48 | | - } |
49 | | - } |
50 | | - |
51 | | - then("crash") { |
52 | | - runs { ctx -> |
53 | | - isCrashRequested = true |
54 | | - Command.SINGLE_SUCCESS |
55 | | - } |
56 | | - } |
57 | | - }.register() |
| 41 | + ClientCommandRegistrationCallback.EVENT.register { dispatcher, _ -> |
| 42 | + dispatcher.register( |
| 43 | + ClientCommands.literal("crashpatch") |
| 44 | + .then(ClientCommands.literal("reload").executes { |
| 45 | + CrashScanner.submitCacheRequest() |
| 46 | + val content = "Requested reload of crash data! Please wait." to CommonColors.GREEN |
| 47 | + val (message, color) = content |
| 48 | + mc.gui.chat.addClientSystemMessage(Component.literal("[${CrashPatchConstants.NAME}] $message").withColor(color)) |
| 49 | + Command.SINGLE_SUCCESS |
| 50 | + }) |
| 51 | + .then(ClientCommands.literal("crash").executes { |
| 52 | + isCrashRequested = true |
| 53 | + Command.SINGLE_SUCCESS |
| 54 | + }) |
| 55 | + ) |
| 56 | + } |
58 | 57 | } |
59 | 58 | } |
0 commit comments