Skip to content

Commit

Permalink
Rewrite FormattedComponentArgument to use markdown (#673)
Browse files Browse the repository at this point in the history
* Rewrite FormattedComponentArgument to use markdown

* Fix markdown links

* Address review comments

* Add tests and fix a couple of bugs
  • Loading branch information
Earthcomputer authored Nov 26, 2024
1 parent 6d16d09 commit 131fb20
Show file tree
Hide file tree
Showing 7 changed files with 618 additions and 251 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ dependencies {

testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
testImplementation "org.junit.jupiter:junit-jupiter:${project.junit_version}"
testImplementation "com.code-intelligence:jazzer-junit:${project.jazzer_junit_version}"
}

test {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ org.gradle.jvmargs=-Xmx2G
seedfinding_seed_version=1.171.2
latticg_version=1.07

jazzer_junit_version=0.22.1
junit_version=5.11.3
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.network.chat.MutableComponent;

import static net.earthcomputer.clientcommands.command.arguments.FormattedComponentArgument.*;
import static net.earthcomputer.clientcommands.command.arguments.ExtendedMarkdownArgument.*;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.*;

public class NoteCommand {

public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(literal("cnote")
.then(argument("message", formattedComponent())
.executes(ctx -> note(ctx.getSource(), getFormattedComponent(ctx, "message")))));
.then(argument("message", extendedMarkdown())
.executes(ctx -> note(ctx.getSource(), getExtendedMarkdown(ctx, "message")))));
}

private static int note(FabricClientCommandSource source, MutableComponent message) {
Expand Down

Large diffs are not rendered by default.

This file was deleted.

1 change: 1 addition & 0 deletions src/main/resources/assets/clientcommands/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@

"commands.client.blockpos": "(%s, %s, %s)",
"commands.client.cancel": "Cancel",
"commands.client.componentTooDeeplyNested": "Chat component too deeply nested",
"commands.client.crack": "Crack",
"commands.client.enable": "Enable",
"commands.client.expectedRegex": "Invalid regex %s",
Expand Down
Loading

0 comments on commit 131fb20

Please sign in to comment.